

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>dcase_framework.features &mdash; DCASE2017 Baseline 1.0 documentation</title>
  

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  
  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  

  
    <link rel="stylesheet" href="../../_static/theme_overrides.css" type="text/css" />
  

  
        <link rel="index" title="Index"
              href="../../genindex.html"/>
        <link rel="search" title="Search" href="../../search.html"/>
    <link rel="top" title="DCASE2017 Baseline 1.0 documentation" href="../../index.html"/>
        <link rel="up" title="Module code" href="../index.html"/> 

  
  <script src="../../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../../index.html" class="icon icon-home"> DCASE2017 Baseline
          

          
            
            <img src="../../_static/dcase2017_baseline.png" class="logo" />
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Baseline system</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../system_description.html">System description</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../system_description.html#mlp-based-system-dcase2017-baseline">MLP based system, DCASE2017 baseline</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../system_description.html#gmm-based-approach">GMM based approach</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../system_description.html#processing-blocks">Processing blocks</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../applications.html">Applications</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../applications.html#task1-acoustic-scene-classification"> Acoustic scene classification</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../applications.html#results">Results</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../applications.html#task2-detection-of-rare-sound-events"> Detection of rare sound events</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../applications.html#id2">Results</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../applications.html#task3-sound-event-detection-in-real-life-audio"> Sound event detection in real life audio</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../applications.html#id3">Results</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../install.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../usage_tutorial.html">Usage</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../usage_tutorial.html#application-arguments">Application arguments</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../usage_tutorial.html#basic-usage">Basic usage</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../parameterization.html">Parameterization</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../parameterization.html#parameter-overwriting">Parameter overwriting</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../parameterization.html#parameter-file">Parameter file</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../parameterization.html#parameter-hash">Parameter hash</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../parameterization.html#parameter-sections">Parameter sections</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#flow">Flow</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#general">General</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#path">Path</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#dataset">Dataset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#feature-extractor">Feature extractor</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#feature-stacker">Feature stacker</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#feature-normalizer">Feature normalizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#feature-aggregator">Feature aggregator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#learner">Learner</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#recognizer">Recognizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#evaluator">Evaluator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#logging">Logging</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../reproducibility.html">Reproducibility</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../reproducibility.html#blas-libraries">BLAS libraries</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../reproducibility.html#intel-math-kernel">Intel Math Kernel</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../reproducibility.html#running-the-baseline-system">Running the baseline system</a></li>
</ul>
</li>
</ul>
<p class="caption"><span class="caption-text">DCASE Framework</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../framework.html">Introduction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../framework.html#training-process">Training process</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../framework.html#testing-process">Testing process</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../extending_framework.html">Extending the framework</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../extending_framework.html#adding-datasets">Adding datasets</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../extending_framework.html#adding-features">Adding features</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../extending_framework.html#addinng-learners">Addinng learners</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../extending_framework.html#extending-applicationcore">Extending ApplicationCore</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../application_core.html">Application core</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../application_core.html#acousticsceneclassificationappcore">AcousticSceneClassificationAppCore</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.html">dcase_framework.application_core.AcousticSceneClassificationAppCore</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.show_dataset_list.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.show_dataset_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.show_parameters.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.show_parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.initialize.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.initialize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.feature_extraction.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.feature_extraction</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.feature_normalization.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.feature_normalization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.system_training.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.system_training</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.system_testing.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.system_testing</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.system_evaluation.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.system_evaluation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../application_core.html#soundeventappcore">SoundEventAppCore</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.html">dcase_framework.application_core.SoundEventAppCore</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.show_dataset_list.html">dcase_framework.application_core.SoundEventAppCore.show_dataset_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.show_parameters.html">dcase_framework.application_core.SoundEventAppCore.show_parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.initialize.html">dcase_framework.application_core.SoundEventAppCore.initialize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.feature_extraction.html">dcase_framework.application_core.SoundEventAppCore.feature_extraction</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.feature_normalization.html">dcase_framework.application_core.SoundEventAppCore.feature_normalization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.system_training.html">dcase_framework.application_core.SoundEventAppCore.system_training</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.system_testing.html">dcase_framework.application_core.SoundEventAppCore.system_testing</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.system_evaluation.html">dcase_framework.application_core.SoundEventAppCore.system_evaluation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../application_core.html#binarysoundeventappcore">BinarySoundEventAppCore</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.html">dcase_framework.application_core.BinarySoundEventAppCore</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.show_dataset_list.html">dcase_framework.application_core.BinarySoundEventAppCore.show_dataset_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.show_parameters.html">dcase_framework.application_core.BinarySoundEventAppCore.show_parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.initialize.html">dcase_framework.application_core.BinarySoundEventAppCore.initialize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.feature_extraction.html">dcase_framework.application_core.BinarySoundEventAppCore.feature_extraction</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.feature_normalization.html">dcase_framework.application_core.BinarySoundEventAppCore.feature_normalization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.system_training.html">dcase_framework.application_core.BinarySoundEventAppCore.system_training</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.system_testing.html">dcase_framework.application_core.BinarySoundEventAppCore.system_testing</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.system_evaluation.html">dcase_framework.application_core.BinarySoundEventAppCore.system_evaluation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../application_core.html#appcore-base-class">AppCore &#8211; base class</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.html">dcase_framework.application_core.AppCore</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.show_dataset_list.html">dcase_framework.application_core.AppCore.show_dataset_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.show_parameters.html">dcase_framework.application_core.AppCore.show_parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.initialize.html">dcase_framework.application_core.AppCore.initialize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.feature_extraction.html">dcase_framework.application_core.AppCore.feature_extraction</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.feature_normalization.html">dcase_framework.application_core.AppCore.feature_normalization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.system_training.html">dcase_framework.application_core.AppCore.system_training</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.system_testing.html">dcase_framework.application_core.AppCore.system_testing</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.system_evaluation.html">dcase_framework.application_core.AppCore.system_evaluation</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../parameters.html">Parameters</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../parameters.html#recipe">Recipe</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../parameters.html#paths-and-parameter-hash">Paths and parameter hash</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../parameters.html#parametercontainer">ParameterContainer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.html">dcase_framework.parameters.ParameterContainer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.load.html">dcase_framework.parameters.ParameterContainer.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.save.html">dcase_framework.parameters.ParameterContainer.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.exists.html">dcase_framework.parameters.ParameterContainer.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.get_path.html">dcase_framework.parameters.ParameterContainer.get_path</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.show.html">dcase_framework.parameters.ParameterContainer.show</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.log.html">dcase_framework.parameters.ParameterContainer.log</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.override.html">dcase_framework.parameters.ParameterContainer.override</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.process.html">dcase_framework.parameters.ParameterContainer.process</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.process_method_parameters.html">dcase_framework.parameters.ParameterContainer.process_method_parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.get_hash.html">dcase_framework.parameters.ParameterContainer.get_hash</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../files.html">Files</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#audiofile">AudioFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.AudioFile.html">dcase_framework.files.AudioFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.AudioFile.load.html">dcase_framework.files.AudioFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.AudioFile.save.html">dcase_framework.files.AudioFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.AudioFile.exists.html">dcase_framework.files.AudioFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.AudioFile.empty.html">dcase_framework.files.AudioFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#parameterfile">ParameterFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ParameterFile.html">dcase_framework.files.ParameterFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ParameterFile.load.html">dcase_framework.files.ParameterFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ParameterFile.save.html">dcase_framework.files.ParameterFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ParameterFile.exists.html">dcase_framework.files.ParameterFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ParameterFile.empty.html">dcase_framework.files.ParameterFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#featurefile">FeatureFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FeatureFile.html">dcase_framework.files.FeatureFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FeatureFile.load.html">dcase_framework.files.FeatureFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FeatureFile.save.html">dcase_framework.files.FeatureFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FeatureFile.exists.html">dcase_framework.files.FeatureFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FeatureFile.empty.html">dcase_framework.files.FeatureFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#datafile">DataFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DataFile.html">dcase_framework.files.DataFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DataFile.load.html">dcase_framework.files.DataFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DataFile.save.html">dcase_framework.files.DataFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DataFile.exists.html">dcase_framework.files.DataFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DataFile.empty.html">dcase_framework.files.DataFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#repositoryfile">RepositoryFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.RepositoryFile.html">dcase_framework.files.RepositoryFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.RepositoryFile.load.html">dcase_framework.files.RepositoryFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.RepositoryFile.exists.html">dcase_framework.files.RepositoryFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.RepositoryFile.empty.html">dcase_framework.files.RepositoryFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#textfile">TextFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.TextFile.html">dcase_framework.files.TextFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.TextFile.load.html">dcase_framework.files.TextFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.TextFile.save.html">dcase_framework.files.TextFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.TextFile.exists.html">dcase_framework.files.TextFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.TextFile.empty.html">dcase_framework.files.TextFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#dictfile">DictFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DictFile.html">dcase_framework.files.DictFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DictFile.load.html">dcase_framework.files.DictFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DictFile.save.html">dcase_framework.files.DictFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DictFile.exists.html">dcase_framework.files.DictFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DictFile.empty.html">dcase_framework.files.DictFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#listfile">ListFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ListFile.html">dcase_framework.files.ListFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ListFile.load.html">dcase_framework.files.ListFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ListFile.save.html">dcase_framework.files.ListFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ListFile.exists.html">dcase_framework.files.ListFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ListFile.empty.html">dcase_framework.files.ListFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#mixins">Mixins</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FileMixin.html">dcase_framework.files.FileMixin</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../datasets.html">Datasets</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../datasets.html#dataset-base-class">Dataset - Base class</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.html">dcase_framework.datasets.Dataset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.initialize.html">dcase_framework.datasets.Dataset.initialize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.show_info.html">dcase_framework.datasets.Dataset.show_info</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.audio_files.html">dcase_framework.datasets.Dataset.audio_files</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.audio_file_count.html">dcase_framework.datasets.Dataset.audio_file_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.meta.html">dcase_framework.datasets.Dataset.meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.meta_count.html">dcase_framework.datasets.Dataset.meta_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.error_meta.html">dcase_framework.datasets.Dataset.error_meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.error_meta_count.html">dcase_framework.datasets.Dataset.error_meta_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.fold_count.html">dcase_framework.datasets.Dataset.fold_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.scene_labels.html">dcase_framework.datasets.Dataset.scene_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.scene_label_count.html">dcase_framework.datasets.Dataset.scene_label_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.event_labels.html">dcase_framework.datasets.Dataset.event_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.event_label_count.html">dcase_framework.datasets.Dataset.event_label_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.audio_tags.html">dcase_framework.datasets.Dataset.audio_tags</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.audio_tag_count.html">dcase_framework.datasets.Dataset.audio_tag_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.download_packages.html">dcase_framework.datasets.Dataset.download_packages</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.extract.html">dcase_framework.datasets.Dataset.extract</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.train.html">dcase_framework.datasets.Dataset.train</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.test.html">dcase_framework.datasets.Dataset.test</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.eval.html">dcase_framework.datasets.Dataset.eval</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.train_files.html">dcase_framework.datasets.Dataset.train_files</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.test_files.html">dcase_framework.datasets.Dataset.test_files</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.eval_files.html">dcase_framework.datasets.Dataset.eval_files</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.validation_files.html">dcase_framework.datasets.Dataset.validation_files</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.folds.html">dcase_framework.datasets.Dataset.folds</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.file_meta.html">dcase_framework.datasets.Dataset.file_meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.file_error_meta.html">dcase_framework.datasets.Dataset.file_error_meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.file_error_meta.html">dcase_framework.datasets.Dataset.file_error_meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.relative_to_absolute_path.html">dcase_framework.datasets.Dataset.relative_to_absolute_path</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.absolute_to_relative.html">dcase_framework.datasets.Dataset.absolute_to_relative</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../datasets.html#acousticscenedataset">AcousticSceneDataset</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.AcousticSceneDataset.html">dcase_framework.datasets.AcousticSceneDataset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2017_DevelopmentSet.html">dcase_framework.datasets.TUTAcousticScenes_2017_DevelopmentSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2016_DevelopmentSet.html">dcase_framework.datasets.TUTAcousticScenes_2016_DevelopmentSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2016_EvaluationSet.html">dcase_framework.datasets.TUTAcousticScenes_2016_EvaluationSet</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../datasets.html#soundeventdataset">SoundEventDataset</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.SoundEventDataset.html">dcase_framework.datasets.SoundEventDataset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.SoundEventDataset.event_label_count.html">dcase_framework.datasets.SoundEventDataset.event_label_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.SoundEventDataset.event_labels.html">dcase_framework.datasets.SoundEventDataset.event_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.SoundEventDataset.train.html">dcase_framework.datasets.SoundEventDataset.train</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.SoundEventDataset.test.html">dcase_framework.datasets.SoundEventDataset.test</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTRareSoundEvents_2017_DevelopmentSet.html">dcase_framework.datasets.TUTRareSoundEvents_2017_DevelopmentSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2017_DevelopmentSet.html">dcase_framework.datasets.TUTSoundEvents_2017_DevelopmentSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2016_DevelopmentSet.html">dcase_framework.datasets.TUTSoundEvents_2016_DevelopmentSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2016_EvaluationSet.html">dcase_framework.datasets.TUTSoundEvents_2016_EvaluationSet</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../datasets.html#audiotaggingdataset">AudioTaggingDataset</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.AudioTaggingDataset.html">dcase_framework.datasets.AudioTaggingDataset</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../metadata.html">Meta data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../metadata.html#metadataitem">MetaDataItem</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.html">dcase_framework.metadata.MetaDataItem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.id.html">dcase_framework.metadata.MetaDataItem.id</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.file.html">dcase_framework.metadata.MetaDataItem.file</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.scene_label.html">dcase_framework.metadata.MetaDataItem.scene_label</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.event_label.html">dcase_framework.metadata.MetaDataItem.event_label</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.event_onset.html">dcase_framework.metadata.MetaDataItem.event_onset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.event_offset.html">dcase_framework.metadata.MetaDataItem.event_offset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.identifier.html">dcase_framework.metadata.MetaDataItem.identifier</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.source_label.html">dcase_framework.metadata.MetaDataItem.source_label</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../metadata.html#metadatacontainer">MetaDataContainer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.html">dcase_framework.metadata.MetaDataContainer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.log.html">dcase_framework.metadata.MetaDataContainer.log</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.show.html">dcase_framework.metadata.MetaDataContainer.show</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.get_string.html">dcase_framework.metadata.MetaDataContainer.get_string</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.update.html">dcase_framework.metadata.MetaDataContainer.update</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.filter.html">dcase_framework.metadata.MetaDataContainer.filter</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.filter_time_segment.html">dcase_framework.metadata.MetaDataContainer.filter_time_segment</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.process_events.html">dcase_framework.metadata.MetaDataContainer.process_events</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.remove_field.html">dcase_framework.metadata.MetaDataContainer.remove_field</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.slice_field.html">dcase_framework.metadata.MetaDataContainer.slice_field</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.filter_time_segment.html">dcase_framework.metadata.MetaDataContainer.filter_time_segment</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.add_time_offset.html">dcase_framework.metadata.MetaDataContainer.add_time_offset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.file_list.html">dcase_framework.metadata.MetaDataContainer.file_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.event_count.html">dcase_framework.metadata.MetaDataContainer.event_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.scene_label_count.html">dcase_framework.metadata.MetaDataContainer.scene_label_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.event_label_count.html">dcase_framework.metadata.MetaDataContainer.event_label_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.unique_scene_labels.html">dcase_framework.metadata.MetaDataContainer.unique_scene_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.unique_event_labels.html">dcase_framework.metadata.MetaDataContainer.unique_event_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.max_offset.html">dcase_framework.metadata.MetaDataContainer.max_offset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.load.html">dcase_framework.metadata.MetaDataContainer.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.save.html">dcase_framework.metadata.MetaDataContainer.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.event_stat_counts.html">dcase_framework.metadata.MetaDataContainer.event_stat_counts</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.event_roll.html">dcase_framework.metadata.MetaDataContainer.event_roll</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../metadata.html#eventroll">EventRoll</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.EventRoll.html">dcase_framework.metadata.EventRoll</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.EventRoll.roll.html">dcase_framework.metadata.EventRoll.roll</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.EventRoll.pad.html">dcase_framework.metadata.EventRoll.pad</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.EventRoll.plot.html">dcase_framework.metadata.EventRoll.plot</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../metadata.html#probabilityitem">ProbabilityItem</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.html">dcase_framework.metadata.ProbabilityItem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.id.html">dcase_framework.metadata.ProbabilityItem.id</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.file.html">dcase_framework.metadata.ProbabilityItem.file</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.label.html">dcase_framework.metadata.ProbabilityItem.label</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.timestamp.html">dcase_framework.metadata.ProbabilityItem.timestamp</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.probability.html">dcase_framework.metadata.ProbabilityItem.probability</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.get_list.html">dcase_framework.metadata.ProbabilityItem.get_list</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../metadata.html#probabilitycontainer">ProbabilityContainer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.html">dcase_framework.metadata.ProbabilityContainer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.log.html">dcase_framework.metadata.ProbabilityContainer.log</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.show.html">dcase_framework.metadata.ProbabilityContainer.show</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.update.html">dcase_framework.metadata.ProbabilityContainer.update</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.file_list.html">dcase_framework.metadata.ProbabilityContainer.file_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.unique_labels.html">dcase_framework.metadata.ProbabilityContainer.unique_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.filter.html">dcase_framework.metadata.ProbabilityContainer.filter</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.get_string.html">dcase_framework.metadata.ProbabilityContainer.get_string</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.load.html">dcase_framework.metadata.ProbabilityContainer.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.save.html">dcase_framework.metadata.ProbabilityContainer.save</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../features.html">Features</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featurecontainer">FeatureContainer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.html">dcase_framework.features.FeatureContainer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.show.html">dcase_framework.features.FeatureContainer.show</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.log.html">dcase_framework.features.FeatureContainer.log</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.get_path.html">dcase_framework.features.FeatureContainer.get_path</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.shape.html">dcase_framework.features.FeatureContainer.shape</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.channels.html">dcase_framework.features.FeatureContainer.channels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.frames.html">dcase_framework.features.FeatureContainer.frames</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.vector_length.html">dcase_framework.features.FeatureContainer.vector_length</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.feat.html">dcase_framework.features.FeatureContainer.feat</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.stat.html">dcase_framework.features.FeatureContainer.stat</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.meta.html">dcase_framework.features.FeatureContainer.meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.load.html">dcase_framework.features.FeatureContainer.load</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featurerepository">FeatureRepository</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureRepository.html">dcase_framework.features.FeatureRepository</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureRepository.show.html">dcase_framework.features.FeatureRepository.show</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureRepository.log.html">dcase_framework.features.FeatureRepository.log</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureRepository.get_path.html">dcase_framework.features.FeatureRepository.get_path</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureRepository.load.html">dcase_framework.features.FeatureRepository.load</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featureextractor">FeatureExtractor</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureExtractor.html">dcase_framework.features.FeatureExtractor</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureExtractor.extract.html">dcase_framework.features.FeatureExtractor.extract</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureExtractor.get_default_parameters.html">dcase_framework.features.FeatureExtractor.get_default_parameters</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featurenormalizer">FeatureNormalizer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureNormalizer.html">dcase_framework.features.FeatureNormalizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureNormalizer.accumulate.html">dcase_framework.features.FeatureNormalizer.accumulate</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureNormalizer.finalize.html">dcase_framework.features.FeatureNormalizer.finalize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureNormalizer.normalize.html">dcase_framework.features.FeatureNormalizer.normalize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureNormalizer.process.html">dcase_framework.features.FeatureNormalizer.process</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featurestacker">FeatureStacker</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureStacker.html">dcase_framework.features.FeatureStacker</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureStacker.normalizer.html">dcase_framework.features.FeatureStacker.normalizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureStacker.feature_vector.html">dcase_framework.features.FeatureStacker.feature_vector</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureStacker.process.html">dcase_framework.features.FeatureStacker.process</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featureaggregator">FeatureAggregator</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureAggregator.html">dcase_framework.features.FeatureAggregator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureAggregator.process.html">dcase_framework.features.FeatureAggregator.process</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featuremasker">FeatureMasker</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureMasker.html">dcase_framework.features.FeatureMasker</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureMasker.process.html">dcase_framework.features.FeatureMasker.process</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../learners.html">Learners</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../learners.html#sceneclassifier">SceneClassifier</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#sceneclassifiergmm">SceneClassifierGMM</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierGMM.html">dcase_framework.learners.SceneClassifierGMM</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierGMM.learn.html">dcase_framework.learners.SceneClassifierGMM.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierGMM.predict.html">dcase_framework.learners.SceneClassifierGMM.predict</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#sceneclassifiermlp">SceneClassifierMLP</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierMLP.html">dcase_framework.learners.SceneClassifierMLP</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierMLP.learn.html">dcase_framework.learners.SceneClassifierMLP.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierMLP.predict.html">dcase_framework.learners.SceneClassifierMLP.predict</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#sceneclassifierkerassequential">SceneClassifierKerasSequential</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierKerasSequential.html">dcase_framework.learners.SceneClassifierKerasSequential</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierKerasSequential.learn.html">dcase_framework.learners.SceneClassifierKerasSequential.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierKerasSequential.predict.html">dcase_framework.learners.SceneClassifierKerasSequential.predict</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../learners.html#eventdetector">EventDetector</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetector.html">dcase_framework.learners.EventDetector</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#eventdetectorgmm">EventDetectorGMM</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorGMM.html">dcase_framework.learners.EventDetectorGMM</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorGMM.learn.html">dcase_framework.learners.EventDetectorGMM.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorGMM.predict.html">dcase_framework.learners.EventDetectorGMM.predict</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#eventdetectormlp">EventDetectorMLP</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorMLP.html">dcase_framework.learners.EventDetectorMLP</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorMLP.learn.html">dcase_framework.learners.EventDetectorMLP.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorMLP.predict.html">dcase_framework.learners.EventDetectorMLP.predict</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#eventdetectorkerassequential">EventDetectorKerasSequential</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorKerasSequential.html">dcase_framework.learners.EventDetectorKerasSequential</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorKerasSequential.learn.html">dcase_framework.learners.EventDetectorKerasSequential.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorKerasSequential.predict.html">dcase_framework.learners.EventDetectorKerasSequential.predict</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../learners.html#learnercontainer-base-class">LearnerContainer - Base class</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.html">dcase_framework.learners.LearnerContainer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.class_labels.html">dcase_framework.learners.LearnerContainer.class_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.method.html">dcase_framework.learners.LearnerContainer.method</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.params.html">dcase_framework.learners.LearnerContainer.params</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.feature_masker.html">dcase_framework.learners.LearnerContainer.feature_masker</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.feature_normalizer.html">dcase_framework.learners.LearnerContainer.feature_normalizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.feature_stacker.html">dcase_framework.learners.LearnerContainer.feature_stacker</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.feature_aggregator.html">dcase_framework.learners.LearnerContainer.feature_aggregator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.model.html">dcase_framework.learners.LearnerContainer.model</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.set_seed.html">dcase_framework.learners.LearnerContainer.set_seed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.learner_params.html">dcase_framework.learners.LearnerContainer.learner_params</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../recognizers.html">Recognizers</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../recognizers.html#scenerecognizer">SceneRecognizer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.SceneRecognizer.html">dcase_framework.recognizers.SceneRecognizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.SceneRecognizer.process.html">dcase_framework.recognizers.SceneRecognizer.process</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../recognizers.html#eventrecognizer">EventRecognizer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.EventRecognizer.html">dcase_framework.recognizers.EventRecognizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.EventRecognizer.process.html">dcase_framework.recognizers.EventRecognizer.process</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.EventRecognizer.process_ratio.html">dcase_framework.recognizers.EventRecognizer.process_ratio</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../recognizers.html#baserecognizer">BaseRecognizer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.BaseRecognizer.html">dcase_framework.recognizers.BaseRecognizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.BaseRecognizer.collapse_probabilities.html">dcase_framework.recognizers.BaseRecognizer.collapse_probabilities</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.BaseRecognizer.collapse_probabilities_windowed.html">dcase_framework.recognizers.BaseRecognizer.collapse_probabilities_windowed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.BaseRecognizer.find_contiguous_regions.html">dcase_framework.recognizers.BaseRecognizer.find_contiguous_regions</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.BaseRecognizer.process_activity.html">dcase_framework.recognizers.BaseRecognizer.process_activity</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../data.html">Data utils</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../data.html#datasequencer">DataSequencer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataSequencer.html">dcase_framework.data.DataSequencer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataSequencer.process.html">dcase_framework.data.DataSequencer.process</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataSequencer.increase_shifting.html">dcase_framework.data.DataSequencer.increase_shifting</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../data.html#dataprocessor">DataProcessor</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.html">dcase_framework.data.DataProcessor</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.load.html">dcase_framework.data.DataProcessor.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.process.html">dcase_framework.data.DataProcessor.process</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.process_features.html">dcase_framework.data.DataProcessor.process_features</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.process_activity_data.html">dcase_framework.data.DataProcessor.process_activity_data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.process_data.html">dcase_framework.data.DataProcessor.process_data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.call_method.html">dcase_framework.data.DataProcessor.call_method</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../data.html#databuffer">DataBuffer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.html">dcase_framework.data.DataBuffer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.count.html">dcase_framework.data.DataBuffer.count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.full.html">dcase_framework.data.DataBuffer.full</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.key_exists.html">dcase_framework.data.DataBuffer.key_exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.set.html">dcase_framework.data.DataBuffer.set</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.get.html">dcase_framework.data.DataBuffer.get</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.clear.html">dcase_framework.data.DataBuffer.clear</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../data.html#processingchain">ProcessingChain</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.ProcessingChain.html">dcase_framework.data.ProcessingChain</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.ProcessingChain.process.html">dcase_framework.data.ProcessingChain.process</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.ProcessingChain.call_method.html">dcase_framework.data.ProcessingChain.call_method</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../keras_utils.html">Keras utils</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#kerasmixin">KerasMixin</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.create_model.html">dcase_framework.keras_utils.KerasMixin.create_model</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.create_callback_list.html">dcase_framework.keras_utils.KerasMixin.create_callback_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.create_external_metric_evaluators.html">dcase_framework.keras_utils.KerasMixin.create_external_metric_evaluators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.prepare_data.html">dcase_framework.keras_utils.KerasMixin.prepare_data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.prepare_activity.html">dcase_framework.keras_utils.KerasMixin.prepare_activity</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.keras_model_exists.html">dcase_framework.keras_utils.KerasMixin.keras_model_exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.log_model_summary.html">dcase_framework.keras_utils.KerasMixin.log_model_summary</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.plot_model.html">dcase_framework.keras_utils.KerasMixin.plot_model</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.get_processing_interval.html">dcase_framework.keras_utils.KerasMixin.get_processing_interval</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#basecallback">BaseCallback</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseCallback.html">dcase_framework.keras_utils.BaseCallback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#progressloggercallback">ProgressLoggerCallback</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.ProgressLoggerCallback.html">dcase_framework.keras_utils.ProgressLoggerCallback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#progressplottercallback">ProgressPlotterCallback</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.ProgressPlotterCallback.html">dcase_framework.keras_utils.ProgressPlotterCallback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#stoppercallback">StopperCallback</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.StopperCallback.html">dcase_framework.keras_utils.StopperCallback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#stashercallback">StasherCallback</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.StasherCallback.html">dcase_framework.keras_utils.StasherCallback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#basedatagenerator">BaseDataGenerator</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseDataGenerator.html">dcase_framework.keras_utils.BaseDataGenerator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseDataGenerator.input_size.html">dcase_framework.keras_utils.BaseDataGenerator.input_size</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseDataGenerator.data_size.html">dcase_framework.keras_utils.BaseDataGenerator.data_size</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseDataGenerator.steps_count.html">dcase_framework.keras_utils.BaseDataGenerator.steps_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseDataGenerator.info.html">dcase_framework.keras_utils.BaseDataGenerator.info</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#featuregenerator">FeatureGenerator</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.FeatureGenerator.html">dcase_framework.keras_utils.FeatureGenerator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.FeatureGenerator.generator.html">dcase_framework.keras_utils.FeatureGenerator.generator</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../ui.html">User interfacing</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../ui.html#fancylogger">FancyLogger</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.html">dcase_framework.ui.FancyLogger</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.title.html">dcase_framework.ui.FancyLogger.title</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.section_header.html">dcase_framework.ui.FancyLogger.section_header</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.foot.html">dcase_framework.ui.FancyLogger.foot</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.line.html">dcase_framework.ui.FancyLogger.line</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.data.html">dcase_framework.ui.FancyLogger.data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.info.html">dcase_framework.ui.FancyLogger.info</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.debug.html">dcase_framework.ui.FancyLogger.debug</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.error.html">dcase_framework.ui.FancyLogger.error</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../utils.html">Utils</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../utils.html#utility-functions">Utility functions</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.setup_logging.html">dcase_framework.utils.setup_logging</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.get_parameter_hash.html">dcase_framework.utils.get_parameter_hash</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.get_class_inheritors.html">dcase_framework.utils.get_class_inheritors</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.get_byte_string.html">dcase_framework.utils.get_byte_string</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.argument_file_exists.html">dcase_framework.utils.argument_file_exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.filelist_exists.html">dcase_framework.utils.filelist_exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.posix_path.html">dcase_framework.utils.posix_path</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../utils.html#timer">Timer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.Timer.html">dcase_framework.utils.Timer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.Timer.start.html">dcase_framework.utils.Timer.start</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.Timer.stop.html">dcase_framework.utils.Timer.stop</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.Timer.elapsed.html">dcase_framework.utils.Timer.elapsed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.Timer.get_string.html">dcase_framework.utils.Timer.get_string</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../utils.html#suppressstdoutandstderr">SuppressStdoutAndStderr</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.SuppressStdoutAndStderr.html">dcase_framework.utils.SuppressStdoutAndStderr</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../utils.html#simplemathstringevaluator">SimpleMathStringEvaluator</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.SimpleMathStringEvaluator.html">dcase_framework.utils.SimpleMathStringEvaluator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.SimpleMathStringEvaluator.eval.html">dcase_framework.utils.SimpleMathStringEvaluator.eval</a></li>
</ul>
</li>
</ul>
</li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">DCASE2017 Baseline</a>
        
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../index.html">Module code</a> &raquo;</li>
        
      <li>dcase_framework.features</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for dcase_framework.features</h1><div class="highlight"><pre>
<span></span><span class="ch">#!/usr/bin/env python</span>
<span class="c1"># -*- coding: utf-8 -*-</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Features</span>
<span class="sd">==================</span>
<span class="sd">Classes for feature handling</span>

<span class="sd">FeatureContainer</span>
<span class="sd">^^^^^^^^^^^^^^^^</span>

<span class="sd">Container class to store features along with statistics and meta data. Class is based on dict through</span>
<span class="sd">inheritance of FeatureFile class.</span>

<span class="sd">Usage examples:</span>

<span class="sd">.. code-block:: python</span>
<span class="sd">    :linenos:</span>

<span class="sd">    # Example 1</span>
<span class="sd">    feature_container = FeatureContainer(filename=&#39;features.cpickle&#39;)</span>
<span class="sd">    feature_container.show()</span>
<span class="sd">    feature_container.log()</span>
<span class="sd">    print(&#39;Feature shape={shape}&#39;.format(shape=feature_container.shape))</span>
<span class="sd">    print(&#39;Feature channels={channels}&#39;.format(channels=feature_container.channels))</span>
<span class="sd">    print(&#39;Feature frames={frames}&#39;.format(frames=feature_container.frames))</span>
<span class="sd">    print(&#39;Feature vector length={vector_length}&#39;.format(vector_length=feature_container.vector_length))</span>
<span class="sd">    print(feature_container.feat)</span>
<span class="sd">    print(feature_container.stat)</span>
<span class="sd">    print(feature_container.meta)</span>
<span class="sd">    # Example 2</span>
<span class="sd">    feature_container = FeatureContainer().load(filename=&#39;features.cpickle&#39;)</span>
<span class="sd">    # Example 3</span>
<span class="sd">    feature_repository = FeatureContainer().load(filename_list={&#39;mel&#39;:&#39;mel_features.cpickle&#39;, &#39;mfcc&#39;:&#39;mfcc_features.cpickle&#39;})</span>
<span class="sd">    # Example 4</span>
<span class="sd">    feature_container = FeatureContainer(features=[numpy.ones((100,10)),numpy.ones((100,10))])</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    FeatureContainer</span>
<span class="sd">    FeatureContainer.show</span>
<span class="sd">    FeatureContainer.log</span>
<span class="sd">    FeatureContainer.get_path</span>
<span class="sd">    FeatureContainer.shape</span>
<span class="sd">    FeatureContainer.channels</span>
<span class="sd">    FeatureContainer.frames</span>
<span class="sd">    FeatureContainer.vector_length</span>
<span class="sd">    FeatureContainer.feat</span>
<span class="sd">    FeatureContainer.stat</span>
<span class="sd">    FeatureContainer.meta</span>
<span class="sd">    FeatureContainer.load</span>


<span class="sd">FeatureRepository</span>
<span class="sd">^^^^^^^^^^^^^^^^^</span>

<span class="sd">Feature repository class, where feature containers for each type of features are stored in a dict. Type name is</span>
<span class="sd">used as key.</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    FeatureRepository</span>
<span class="sd">    FeatureRepository.show</span>
<span class="sd">    FeatureRepository.log</span>
<span class="sd">    FeatureRepository.get_path</span>
<span class="sd">    FeatureRepository.load</span>

<span class="sd">FeatureExtractor</span>
<span class="sd">^^^^^^^^^^^^^^^^</span>

<span class="sd">Feature extractor class.</span>

<span class="sd">Usage examples:</span>

<span class="sd">.. code-block:: python</span>
<span class="sd">    :linenos:</span>

<span class="sd">    # Example 1, to get feature only without storing them</span>
<span class="sd">    feature_repository = FeatureExtractor().extract(audio_file=&#39;debug/test.wav&#39;,</span>
<span class="sd">                                                    extractor_name=&#39;mfcc&#39;,</span>
<span class="sd">                                                    extractor_params={</span>
<span class="sd">                                                        &#39;mfcc&#39;: {</span>
<span class="sd">                                                            &#39;n_mfcc&#39;: 10</span>
<span class="sd">                                                        }</span>
<span class="sd">                                                    }</span>
<span class="sd">                                                    )</span>
<span class="sd">    feature_repository[&#39;mfcc&#39;].show()</span>

<span class="sd">    # Example 2, to store features during the extraction</span>
<span class="sd">    feature_repository = FeatureExtractor(store=True).extract(</span>
<span class="sd">        audio_file=&#39;debug/test.wav&#39;,</span>
<span class="sd">        extractor_name=&#39;mfcc&#39;,</span>
<span class="sd">        extractor_params={</span>
<span class="sd">            &#39;mfcc&#39;: {</span>
<span class="sd">                &#39;n_mfcc&#39;: 10</span>
<span class="sd">            }</span>
<span class="sd">        },</span>
<span class="sd">        storage_paths={</span>
<span class="sd">            &#39;mfcc&#39;: &#39;debug/test.mfcc.cpickle&#39;</span>
<span class="sd">        }</span>
<span class="sd">    )</span>

<span class="sd">    # Example 3</span>
<span class="sd">    print(FeatureExtractor().get_default_parameters())</span>


<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    FeatureExtractor</span>
<span class="sd">    FeatureExtractor.extract</span>
<span class="sd">    FeatureExtractor.get_default_parameters</span>

<span class="sd">FeatureNormalizer</span>
<span class="sd">^^^^^^^^^^^^^^^^^</span>

<span class="sd">Feature normalizer class.</span>

<span class="sd">Usage examples:</span>

<span class="sd">.. code-block:: python</span>
<span class="sd">    :linenos:</span>

<span class="sd">    # Example 1</span>
<span class="sd">    normalizer = FeatureNormalizer()</span>
<span class="sd">    for feature_matrix in training_items:</span>
<span class="sd">         normalizer.accumulate(feature_matrix)</span>
<span class="sd">    normalizer.finalize()</span>

<span class="sd">    for feature_matrix in test_items:</span>
<span class="sd">        feature_matrix_normalized = normalizer.normalizer(feature_matrix)</span>
<span class="sd">        # used the features</span>

<span class="sd">    # Example 2</span>
<span class="sd">    with FeatureNormalizer() as norm:</span>
<span class="sd">        norm.accumulate(feature_repository[&#39;mfcc&#39;])</span>

<span class="sd">    for feature_matrix in test_items:</span>
<span class="sd">        feature_matrix_normalized = normalizer.normalizer(feature_matrix)</span>
<span class="sd">        # used the features</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    FeatureNormalizer</span>
<span class="sd">    FeatureNormalizer.accumulate</span>
<span class="sd">    FeatureNormalizer.finalize</span>
<span class="sd">    FeatureNormalizer.normalize</span>
<span class="sd">    FeatureNormalizer.process</span>

<span class="sd">FeatureStacker</span>
<span class="sd">^^^^^^^^^^^^^^</span>

<span class="sd">Feature stacking class. Class takes feature vector recipe and FeatureRepository, and creates appropriate feature matrix.</span>


<span class="sd">**Feature vector recipe**</span>

<span class="sd">With a recipe one can either select full matrix, only part of with start and end index, or select individual rows from it.</span>

<span class="sd">Example recipe:</span>

<span class="sd">.. code-block:: python</span>
<span class="sd">    :linenos:</span>

<span class="sd">    [</span>
<span class="sd">     {</span>
<span class="sd">        &#39;method&#39;: &#39;mfcc&#39;,</span>
<span class="sd">     },</span>
<span class="sd">     {</span>
<span class="sd">        &#39;method&#39;: &#39;mfcc_delta&#39;</span>
<span class="sd">        &#39;vector-index: {</span>
<span class="sd">            &#39;channel&#39;: 0,</span>
<span class="sd">            &#39;start&#39;: 1,</span>
<span class="sd">            &#39;end&#39;: 17,</span>
<span class="sd">            &#39;full&#39;: False,</span>
<span class="sd">            &#39;selection&#39;: False,</span>
<span class="sd">        }</span>
<span class="sd">      },</span>
<span class="sd">     {</span>
<span class="sd">        &#39;method&#39;: &#39;mfcc_acceleration&#39;,</span>
<span class="sd">        &#39;vector-index: {</span>
<span class="sd">            &#39;channel&#39;: 0,</span>
<span class="sd">            &#39;full&#39;: False,</span>
<span class="sd">            &#39;selection&#39;: True,</span>
<span class="sd">            &#39;vector&#39;: [2, 4, 6]</span>
<span class="sd">        }</span>
<span class="sd">     }</span>
<span class="sd">    ]</span>

<span class="sd">See  :py:meth:`dcase_framework.ParameterContainer._parse_recipe` how text recipe can be confiniently used to generate</span>
<span class="sd">above structure.</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    FeatureStacker</span>
<span class="sd">    FeatureStacker.normalizer</span>
<span class="sd">    FeatureStacker.feature_vector</span>
<span class="sd">    FeatureStacker.process</span>


<span class="sd">FeatureAggregator</span>
<span class="sd">^^^^^^^^^^^^^^^^^</span>

<span class="sd">Feature aggregator can be used to process feature matrix in a processing windows.</span>
<span class="sd">This processing stage can be used to collapse features within certain window lengths by</span>
<span class="sd">calculating mean and std of them, or flatten the matrix into one feature vector.</span>

<span class="sd">Supported processing methods:</span>

<span class="sd">- ``flatten``</span>
<span class="sd">- ``mean``</span>
<span class="sd">- ``std``</span>
<span class="sd">- ``cov``</span>
<span class="sd">- ``kurtosis``</span>
<span class="sd">- ``skew``</span>

<span class="sd">The processing methods can combined.</span>

<span class="sd">Usage examples:</span>

<span class="sd">.. code-block:: python</span>
<span class="sd">    :linenos:</span>

<span class="sd">    feature_aggregator = FeatureAggregator(</span>
<span class="sd">        recipe=[&#39;mean&#39;, &#39;std&#39;],</span>
<span class="sd">        win_length_frames=10,</span>
<span class="sd">        hop_length_frames=1,</span>
<span class="sd">    )</span>

<span class="sd">    feature_stacker = FeatureStacker(recipe=[{&#39;method&#39;: &#39;mfcc&#39;}])</span>
<span class="sd">    feature_repository = FeatureContainer().load(filename_list={&#39;mfcc&#39;: &#39;mfcc.cpickle&#39;})</span>
<span class="sd">    feature_matrix = feature_stacker.feature_vector(feature_repository=feature_repository)</span>
<span class="sd">    feature_matrix = feature_aggregator.process(feature_container=feature_matrix)</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    FeatureAggregator</span>
<span class="sd">    FeatureAggregator.process</span>

<span class="sd">FeatureMasker</span>
<span class="sd">^^^^^^^^^^^^^</span>

<span class="sd">Feature masker can be used to mask segments of feature matrix out. For examples, error segments of signal</span>
<span class="sd">can be excluded from the matrix.</span>

<span class="sd">Usage examples:</span>

<span class="sd">.. code-block:: python</span>
<span class="sd">    :linenos:</span>

<span class="sd">    feature_masker = FeatureMasker(hop_length_seconds=0.01)</span>
<span class="sd">    mask_events = MetaDataContainer([</span>
<span class="sd">        {</span>
<span class="sd">            &#39;event_onset&#39;: 1.0,</span>
<span class="sd">            &#39;event_offset&#39;: 1.5,</span>
<span class="sd">        },</span>
<span class="sd">        {</span>
<span class="sd">            &#39;event_onset&#39;: 2.0,</span>
<span class="sd">            &#39;event_offset&#39;: 2.5,</span>
<span class="sd">        },</span>
<span class="sd">    ])</span>

<span class="sd">    masked_features = feature_masker.process(feature_repository=feature_repository, mask_events=mask_events)</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    FeatureMasker</span>
<span class="sd">    FeatureMasker.process</span>

<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">print_function</span><span class="p">,</span> <span class="n">absolute_import</span>
<span class="kn">from</span> <span class="nn">six</span> <span class="k">import</span> <span class="n">iteritems</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">numpy</span>
<span class="kn">import</span> <span class="nn">librosa</span>
<span class="kn">import</span> <span class="nn">scipy</span>
<span class="kn">import</span> <span class="nn">collections</span>
<span class="kn">import</span> <span class="nn">copy</span>
<span class="kn">from</span> <span class="nn">time</span> <span class="k">import</span> <span class="n">gmtime</span><span class="p">,</span> <span class="n">strftime</span>
<span class="kn">from</span> <span class="nn">.files</span> <span class="k">import</span> <span class="n">FeatureFile</span><span class="p">,</span> <span class="n">AudioFile</span><span class="p">,</span> <span class="n">DataFile</span><span class="p">,</span> <span class="n">RepositoryFile</span>
<span class="kn">from</span> <span class="nn">.containers</span> <span class="k">import</span> <span class="n">ContainerMixin</span><span class="p">,</span> <span class="n">DottedDict</span>
<span class="kn">from</span> <span class="nn">.parameters</span> <span class="k">import</span> <span class="n">ParameterContainer</span>
<span class="kn">from</span> <span class="nn">.utils</span> <span class="k">import</span> <span class="n">filelist_exists</span>
<span class="kn">from</span> <span class="nn">.metadata</span> <span class="k">import</span> <span class="n">MetaDataContainer</span>


<div class="viewcode-block" id="FeatureContainer"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureContainer.html#dcase_framework.features.FeatureContainer">[docs]</a><span class="k">class</span> <span class="nc">FeatureContainer</span><span class="p">(</span><span class="n">FeatureFile</span><span class="p">,</span> <span class="n">ContainerMixin</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Feature container inherited from dict</span>

<span class="sd">    Container has following internal structure:</span>

<span class="sd">    - feat, list of feature matrices, [channel][frames,feature_vector]</span>
<span class="sd">    - stat, list of feature statistics</span>
<span class="sd">    - meta, dict with feature meta data</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;0.0.1&#39;</span>

<div class="viewcode-block" id="FeatureContainer.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureContainer.html#dcase_framework.features.FeatureContainer.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Constructor</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        filename: str, optional</span>
<span class="sd">            If filename is given container is loaded in the initialization stage.</span>
<span class="sd">            Default value &quot;None&quot;</span>

<span class="sd">        features: list, optional</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;filename&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span>
            <span class="nb">super</span><span class="p">(</span><span class="n">FeatureContainer</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">({</span>
                <span class="s1">&#39;feat&#39;</span><span class="p">:</span> <span class="p">[],</span>
                <span class="s1">&#39;stat&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;meta&#39;</span><span class="p">:</span> <span class="p">{},</span>
            <span class="p">})</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;filename&#39;</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;features&#39;</span><span class="p">,</span> <span class="p">[]):</span>
                <span class="nb">super</span><span class="p">(</span><span class="n">FeatureContainer</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">({</span>
                    <span class="s1">&#39;feat&#39;</span><span class="p">:</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;features&#39;</span><span class="p">,</span> <span class="p">[]),</span>
                    <span class="s1">&#39;stat&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                    <span class="s1">&#39;meta&#39;</span><span class="p">:</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;meta&#39;</span><span class="p">,</span> <span class="p">{}),</span>
                <span class="p">})</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="nb">super</span><span class="p">(</span><span class="n">FeatureContainer</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">shape</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Shape of feature matrix</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="s1">&#39;feat&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">channels</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of feature channels</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">            int</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="s1">&#39;feat&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">feat</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">frames</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of feature frames</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">            int</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="s1">&#39;feat&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">vector_length</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Feature vector length</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">            int</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="s1">&#39;feat&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">feat</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Feature data</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">            list of numpy.ndarray</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="s1">&#39;feat&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;feat&#39;</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

    <span class="nd">@feat</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">feat</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;feat&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">stat</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Statistics of feature data</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">            list of dicts</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">feat</span><span class="p">:</span>
            <span class="k">if</span> <span class="s1">&#39;stat&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;stat&#39;</span><span class="p">]:</span>
                <span class="n">stat_container</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">channel_data</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">feat</span><span class="p">:</span>
                    <span class="n">stat_container</span><span class="o">.</span><span class="n">append</span><span class="p">({</span>
                        <span class="s1">&#39;mean&#39;</span><span class="p">:</span> <span class="n">numpy</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">channel_data</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">),</span>
                        <span class="s1">&#39;std&#39;</span><span class="p">:</span> <span class="n">numpy</span><span class="o">.</span><span class="n">std</span><span class="p">(</span><span class="n">channel_data</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">),</span>
                        <span class="s1">&#39;N&#39;</span><span class="p">:</span> <span class="n">channel_data</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                        <span class="s1">&#39;S1&#39;</span><span class="p">:</span> <span class="n">numpy</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">channel_data</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">),</span>
                        <span class="s1">&#39;S2&#39;</span><span class="p">:</span> <span class="n">numpy</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">channel_data</span> <span class="o">**</span> <span class="mi">2</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">),</span>
                    <span class="p">})</span>
                <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;stat&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">stat_container</span>
            <span class="k">return</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;stat&#39;</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">meta</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Meta data</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">            dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="s1">&#39;meta&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;meta&#39;</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

    <span class="nd">@meta</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">meta</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;meta&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>

<div class="viewcode-block" id="FeatureContainer.load"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureContainer.load.html#dcase_framework.features.FeatureContainer.load">[docs]</a>    <span class="k">def</span> <span class="nf">load</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">filename_dict</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Load data into container</span>

<span class="sd">        If filename is given, container is loaded from disk</span>
<span class="sd">        If filename_list is given, a FeatureRepository is created and returned.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        filename : str, optional</span>
<span class="sd">        filename_dict : dict, optional</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">            FeatureContainer or FeatureRepository</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">filename</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">super</span><span class="p">(</span><span class="n">FeatureContainer</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">filename</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">filename_dict</span><span class="p">:</span>
            <span class="n">repository</span> <span class="o">=</span> <span class="n">FeatureRepository</span><span class="p">({})</span>
            <span class="k">for</span> <span class="n">method</span><span class="p">,</span> <span class="n">filename</span> <span class="ow">in</span> <span class="n">iteritems</span><span class="p">(</span><span class="n">filename_dict</span><span class="p">):</span>
                <span class="n">repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span> <span class="o">=</span> <span class="n">FeatureContainer</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">filename</span><span class="p">)</span>

            <span class="k">return</span> <span class="n">repository</span></div></div>


<div class="viewcode-block" id="FeatureRepository"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureRepository.html#dcase_framework.features.FeatureRepository">[docs]</a><span class="k">class</span> <span class="nc">FeatureRepository</span><span class="p">(</span><span class="n">RepositoryFile</span><span class="p">,</span> <span class="n">ContainerMixin</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Feature repository</span>

<span class="sd">    Feature containers for each type of features are stored in a dict. Type name is used as key.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;0.0.1&#39;</span>

<div class="viewcode-block" id="FeatureRepository.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureRepository.html#dcase_framework.features.FeatureRepository.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Constructor</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        filename_dict: dict</span>
<span class="sd">            Dict of file paths, feature extraction method label as key, and filename as value.</span>
<span class="sd">            If given, features are loaded in the initialization stage.</span>
<span class="sd">            Default value &quot;None&quot;</span>

<span class="sd">        features: list, optional</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="nb">super</span><span class="p">(</span><span class="n">FeatureRepository</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;logger&#39;</span><span class="p">,</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;filename_dict&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">filename_dict</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;filename_dict&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">load</span><span class="p">()</span></div>

<div class="viewcode-block" id="FeatureRepository.load"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureRepository.load.html#dcase_framework.features.FeatureRepository.load">[docs]</a>    <span class="k">def</span> <span class="nf">load</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename_dict</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Load file list</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        filename_dict : dict</span>
<span class="sd">            Dict of file paths, feature extraction method label as key, and filename as value.</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        self</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">filename_dict</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">filename_dict</span> <span class="o">=</span> <span class="n">filename_dict</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename_dict</span> <span class="ow">and</span> <span class="n">filelist_exists</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename_dict</span><span class="p">):</span>
            <span class="nb">dict</span><span class="o">.</span><span class="n">clear</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
            <span class="nb">sorted</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename_dict</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">method</span><span class="p">,</span> <span class="n">filename</span> <span class="ow">in</span> <span class="n">iteritems</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename_dict</span><span class="p">):</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">method</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">):</span>
                    <span class="c1"># Skip method starting with &#39;_&#39;, those are just for extra info</span>
                    <span class="bp">self</span><span class="p">[</span><span class="n">method</span><span class="p">]</span> <span class="o">=</span> <span class="n">FeatureContainer</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">filename</span><span class="p">)</span>

            <span class="k">return</span> <span class="bp">self</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Feature repository cannot be loaded [</span><span class="si">{filename_dict}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                <span class="n">filename_dict</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">filename_dict</span>
            <span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
            <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="FeatureExtractor"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureExtractor.html#dcase_framework.features.FeatureExtractor">[docs]</a><span class="k">class</span> <span class="nc">FeatureExtractor</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Feature extractor&quot;&quot;&quot;</span>
    <span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;0.0.1&#39;</span>

<div class="viewcode-block" id="FeatureExtractor.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureExtractor.html#dcase_framework.features.FeatureExtractor.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Constructor</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        store : bool</span>
<span class="sd">            Store features to disk</span>
<span class="sd">            Default value &quot;False&quot;</span>
<span class="sd">        overwrite : bool</span>
<span class="sd">            If set True, features are overwritten on disk</span>
<span class="sd">            Default value &quot;False&quot;</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">eps</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">spacing</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">overwrite</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;overwrite&#39;</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">store</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;store&#39;</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;logger&#39;</span><span class="p">,</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">))</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">valid_extractors</span> <span class="o">=</span> <span class="p">[</span>
            <span class="s1">&#39;mfcc&#39;</span><span class="p">,</span>
            <span class="s1">&#39;mfcc_delta&#39;</span><span class="p">,</span>
            <span class="s1">&#39;mfcc_acceleration&#39;</span><span class="p">,</span>
            <span class="s1">&#39;mel&#39;</span>
        <span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">valid_extractors</span> <span class="o">+=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;valid_extractors&#39;</span><span class="p">,</span> <span class="p">[])</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">default_general_parameters</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;fs&#39;</span><span class="p">:</span> <span class="mi">44100</span><span class="p">,</span>
            <span class="s1">&#39;win_length_samples&#39;</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="mf">0.04</span> <span class="o">*</span> <span class="mi">44100</span><span class="p">),</span>
            <span class="s1">&#39;hop_length_samples&#39;</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="mf">0.02</span> <span class="o">*</span> <span class="mi">44100</span><span class="p">),</span>
        <span class="p">}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">default_general_parameters</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;default_general_parameters&#39;</span><span class="p">,</span> <span class="p">{}))</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">default_parameters</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;mfcc&#39;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s1">&#39;mono&#39;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>  <span class="c1"># [True, False]</span>
                <span class="s1">&#39;window&#39;</span><span class="p">:</span> <span class="s1">&#39;hamming_asymmetric&#39;</span><span class="p">,</span>  <span class="c1"># [hann_asymmetric, hamming_asymmetric]</span>
                <span class="s1">&#39;spectrogram_type&#39;</span><span class="p">:</span> <span class="s1">&#39;magnitude&#39;</span><span class="p">,</span>  <span class="c1"># [magnitude, power]</span>
                <span class="s1">&#39;n_mfcc&#39;</span><span class="p">:</span> <span class="mi">20</span><span class="p">,</span>  <span class="c1"># Number of MFCC coefficients</span>
                <span class="s1">&#39;n_mels&#39;</span><span class="p">:</span> <span class="mi">40</span><span class="p">,</span>  <span class="c1"># Number of MEL bands used</span>
                <span class="s1">&#39;n_fft&#39;</span><span class="p">:</span> <span class="mi">2048</span><span class="p">,</span>  <span class="c1"># FFT length</span>
                <span class="s1">&#39;fmin&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>  <span class="c1"># Minimum frequency when constructing MEL bands</span>
                <span class="s1">&#39;fmax&#39;</span><span class="p">:</span> <span class="mi">22050</span><span class="p">,</span>  <span class="c1"># Maximum frequency when constructing MEL band</span>
                <span class="s1">&#39;htk&#39;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>  <span class="c1"># Switch for HTK-styled MEL-frequency equation</span>
            <span class="p">},</span>
            <span class="s1">&#39;mfcc_delta&#39;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s1">&#39;width&#39;</span><span class="p">:</span> <span class="mi">9</span><span class="p">,</span>
                <span class="s1">&#39;dependency_method&#39;</span><span class="p">:</span> <span class="s1">&#39;mfcc&#39;</span><span class="p">,</span>
            <span class="p">},</span>
            <span class="s1">&#39;mfcc_acceleration&#39;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s1">&#39;width&#39;</span><span class="p">:</span> <span class="mi">9</span><span class="p">,</span>
                <span class="s1">&#39;dependency_method&#39;</span><span class="p">:</span> <span class="s1">&#39;mfcc&#39;</span><span class="p">,</span>
            <span class="p">},</span>
            <span class="s1">&#39;mel&#39;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s1">&#39;mono&#39;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>  <span class="c1"># [True, False]</span>
                <span class="s1">&#39;window&#39;</span><span class="p">:</span> <span class="s1">&#39;hamming_asymmetric&#39;</span><span class="p">,</span>  <span class="c1"># [hann_asymmetric, hamming_asymmetric]</span>
                <span class="s1">&#39;spectrogram_type&#39;</span><span class="p">:</span> <span class="s1">&#39;magnitude&#39;</span><span class="p">,</span>  <span class="c1"># [magnitude, power]</span>
                <span class="s1">&#39;n_mels&#39;</span><span class="p">:</span> <span class="mi">40</span><span class="p">,</span>  <span class="c1"># Number of MEL bands used</span>
                <span class="s1">&#39;normalize_mel_bands&#39;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>  <span class="c1"># [True, False]</span>
                <span class="s1">&#39;n_fft&#39;</span><span class="p">:</span> <span class="mi">2048</span><span class="p">,</span>  <span class="c1"># FFT length</span>
                <span class="s1">&#39;fmin&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>  <span class="c1"># Minimum frequency when constructing MEL bands</span>
                <span class="s1">&#39;fmax&#39;</span><span class="p">:</span> <span class="mi">22050</span><span class="p">,</span>  <span class="c1"># Maximum frequency when constructing MEL band</span>
                <span class="s1">&#39;htk&#39;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>  <span class="c1"># Switch for HTK-styled MEL-frequency equation</span>
                <span class="s1">&#39;log&#39;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>  <span class="c1"># Logarithmic</span>
            <span class="p">}</span>
        <span class="p">}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">default_parameters</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;default_parameters&#39;</span><span class="p">,</span> <span class="p">{}))</span>

        <span class="c1"># Update general parameters and expand dependencies</span>
        <span class="k">for</span> <span class="n">method</span><span class="p">,</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">iteritems</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">default_parameters</span><span class="p">):</span>
            <span class="n">data</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">default_general_parameters</span><span class="p">)</span>
            <span class="k">if</span> <span class="p">(</span><span class="s1">&#39;dependency_method&#39;</span> <span class="ow">in</span> <span class="n">data</span> <span class="ow">and</span>
               <span class="n">data</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">valid_extractors</span> <span class="ow">and</span>
               <span class="n">data</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_parameters</span><span class="p">):</span>

                <span class="n">data</span><span class="p">[</span><span class="s1">&#39;dependency_parameters&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_parameters</span><span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]]</span></div>

    <span class="k">def</span> <span class="nf">__getstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="c1"># Return only needed data for pickle</span>
        <span class="k">return</span> <span class="p">{</span>
            <span class="s1">&#39;eps&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">eps</span><span class="p">,</span>
            <span class="s1">&#39;overwrite&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">overwrite</span><span class="p">,</span>
            <span class="s1">&#39;store&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">store</span><span class="p">,</span>
            <span class="s1">&#39;valid_extractors&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">valid_extractors</span><span class="p">,</span>
            <span class="s1">&#39;default_general_parameters&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_general_parameters</span><span class="p">,</span>
            <span class="s1">&#39;default_parameters&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_parameters</span><span class="p">,</span>
        <span class="p">}</span>

    <span class="k">def</span> <span class="nf">__setstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">eps</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;eps&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">overwrite</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;overwrite&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">store</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;store&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">valid_extractors</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;valid_extractors&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">default_general_parameters</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;default_general_parameters&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">default_parameters</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;default_parameters&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>

<div class="viewcode-block" id="FeatureExtractor.extract"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureExtractor.extract.html#dcase_framework.features.FeatureExtractor.extract">[docs]</a>    <span class="k">def</span> <span class="nf">extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">audio_file</span><span class="p">,</span> <span class="n">extractor_params</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">storage_paths</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">extractor_name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Extract features for audio file</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        audio_file : str</span>
<span class="sd">            Filename of audio file.</span>
<span class="sd">        extractor_params : dict of dicts</span>
<span class="sd">            Keys at first level corresponds to feature extraction methods, and second level is parameters given to the</span>
<span class="sd">            extractor method. If none given, default parameters used.</span>
<span class="sd">        storage_paths : dict of strings</span>
<span class="sd">            Keys at first level corresponds to feature extraction methods, second level is path to store feature</span>
<span class="sd">            containers.</span>
<span class="sd">        extractor_name : str</span>
<span class="sd">            Feature extractor method name, if none given, extractor_params is used. Use this to select specific</span>
<span class="sd">            extractor method.</span>
<span class="sd">            Default value &quot;None&quot;</span>

<span class="sd">        Raises</span>
<span class="sd">        ------</span>
<span class="sd">        ValueError:</span>
<span class="sd">            Unknown extractor method</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        FeatureRepository</span>
<span class="sd">            Repository, a dict of FeatureContainers</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">extractor_params</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">extractor_params</span> <span class="o">=</span> <span class="p">{}</span>

        <span class="k">if</span> <span class="n">storage_paths</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">storage_paths</span> <span class="o">=</span> <span class="p">{}</span>

        <span class="c1"># Get extractor list</span>
        <span class="k">if</span> <span class="n">extractor_name</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">extractor_list</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">extractor_params</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">extractor_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">extractor_name</span><span class="p">]</span>

            <span class="k">if</span> <span class="n">extractor_name</span> <span class="ow">in</span> <span class="n">extractor_params</span><span class="p">:</span>
                <span class="n">extractor_params</span> <span class="o">=</span> <span class="p">{</span>
                    <span class="n">extractor_name</span><span class="p">:</span> <span class="n">extractor_params</span><span class="p">[</span><span class="n">extractor_name</span><span class="p">]</span>
                <span class="p">}</span>

        <span class="c1"># Update (recursively) internal default parameters with given parameters</span>
        <span class="n">extractor_params</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">default_parameters</span><span class="p">,</span> <span class="n">extractor_params</span><span class="p">)</span>

        <span class="c1"># Update general parameters and expand dependencies</span>
        <span class="k">for</span> <span class="n">method</span><span class="p">,</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">iteritems</span><span class="p">(</span><span class="n">extractor_params</span><span class="p">):</span>
            <span class="k">if</span> <span class="p">(</span><span class="s1">&#39;dependency_method&#39;</span> <span class="ow">in</span> <span class="n">data</span> <span class="ow">and</span>
               <span class="n">data</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">valid_extractors</span> <span class="ow">and</span>
               <span class="n">data</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]</span> <span class="ow">in</span> <span class="n">extractor_params</span><span class="p">):</span>

                <span class="n">data</span><span class="p">[</span><span class="s1">&#39;dependency_parameters&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">extractor_params</span><span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]]</span>

        <span class="n">feature_repository</span> <span class="o">=</span> <span class="n">FeatureRepository</span><span class="p">({})</span>
        <span class="k">for</span> <span class="n">extractor_name</span> <span class="ow">in</span> <span class="n">extractor_list</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">extractor_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">valid_extractors</span><span class="p">:</span>
                <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Invalid extractor method [</span><span class="si">{method}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                    <span class="n">method</span><span class="o">=</span><span class="n">extractor_name</span>
                <span class="p">)</span>

                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

            <span class="n">current_extractor_params</span> <span class="o">=</span> <span class="n">extractor_params</span><span class="p">[</span><span class="n">extractor_name</span><span class="p">]</span>

            <span class="n">extract</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="c1"># Check do we need to extract anything</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">overwrite</span> <span class="ow">and</span> <span class="n">extractor_name</span> <span class="ow">in</span> <span class="n">storage_paths</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">storage_paths</span><span class="p">[</span><span class="n">extractor_name</span><span class="p">]):</span>
                <span class="c1"># Load from disk</span>
                <span class="n">feature_repository</span><span class="p">[</span><span class="n">extractor_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FeatureContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">storage_paths</span><span class="p">[</span><span class="n">extractor_name</span><span class="p">])</span>

                <span class="c1"># Check the parameters</span>
                <span class="n">hash1</span> <span class="o">=</span> <span class="n">ParameterContainer</span><span class="p">()</span><span class="o">.</span><span class="n">get_hash</span><span class="p">(</span><span class="n">current_extractor_params</span><span class="p">)</span>
                <span class="n">hash2</span> <span class="o">=</span> <span class="n">ParameterContainer</span><span class="p">()</span><span class="o">.</span><span class="n">get_hash</span><span class="p">(</span><span class="n">feature_repository</span><span class="p">[</span><span class="n">extractor_name</span><span class="p">][</span><span class="s1">&#39;meta&#39;</span><span class="p">][</span><span class="s1">&#39;parameters&#39;</span><span class="p">])</span>
                <span class="k">if</span> <span class="n">hash1</span> <span class="o">==</span> <span class="n">hash2</span><span class="p">:</span>
                    <span class="c1"># The loaded data contains features with same parameters, no need to extract them anymore</span>
                    <span class="n">extract</span> <span class="o">=</span> <span class="kc">False</span>

            <span class="c1"># Feature extraction stage</span>
            <span class="k">if</span> <span class="n">extract</span><span class="p">:</span>
                <span class="c1"># Load audio</span>
                <span class="n">y</span><span class="p">,</span> <span class="n">fs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_load_audio</span><span class="p">(</span><span class="n">audio_file</span><span class="o">=</span><span class="n">audio_file</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="n">current_extractor_params</span><span class="p">)</span>

                <span class="c1"># Check for dependency to other features</span>
                <span class="k">if</span> <span class="s1">&#39;dependency_method&#39;</span> <span class="ow">in</span> <span class="n">current_extractor_params</span> <span class="ow">and</span> <span class="n">current_extractor_params</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]:</span>
                    <span class="c1"># Current extractor is depending on other extractor</span>

                    <span class="k">if</span> <span class="n">current_extractor_params</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">valid_extractors</span><span class="p">:</span>
                        <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Invalid dependency extractor method [</span><span class="si">{method1}</span><span class="s1">] for method [</span><span class="si">{method2}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                            <span class="n">method1</span><span class="o">=</span><span class="n">current_extractor_params</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">],</span>
                            <span class="n">method2</span><span class="o">=</span><span class="n">extractor_name</span>
                        <span class="p">)</span>

                        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

                    <span class="k">if</span> <span class="p">(</span><span class="n">current_extractor_params</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]</span> <span class="ow">in</span> <span class="n">storage_paths</span> <span class="ow">and</span>
                       <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">storage_paths</span><span class="p">[</span><span class="n">current_extractor_params</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]])):</span>

                        <span class="c1"># Load features from disk</span>
                        <span class="n">data</span> <span class="o">=</span> <span class="n">FeatureContainer</span><span class="p">(</span>
                            <span class="n">filename</span><span class="o">=</span><span class="n">storage_paths</span><span class="p">[</span><span class="n">current_extractor_params</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]]</span>
                        <span class="p">)</span><span class="o">.</span><span class="n">feat</span>

                    <span class="k">else</span><span class="p">:</span>
                        <span class="c1"># Extract features</span>
                        <span class="n">dependency_func</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">&#39;_</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">current_extractor_params</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]),</span> <span class="kc">None</span><span class="p">)</span>
                        <span class="k">if</span> <span class="n">dependency_func</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                            <span class="n">data</span> <span class="o">=</span> <span class="n">dependency_func</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">y</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="n">current_extractor_params</span><span class="p">[</span><span class="s1">&#39;dependency_parameters&#39;</span><span class="p">])</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: No extraction method for dependency extractor [</span><span class="si">{method}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                                <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                                <span class="n">method</span><span class="o">=</span><span class="n">current_extractor_params</span><span class="p">[</span><span class="s1">&#39;dependency_method&#39;</span><span class="p">]</span>
                            <span class="p">)</span>

                            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

                <span class="k">else</span><span class="p">:</span>
                    <span class="c1"># By pass</span>
                    <span class="n">data</span> <span class="o">=</span> <span class="n">y</span>

                <span class="c1"># Extract features</span>
                <span class="n">extractor_func</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">&#39;_</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">extractor_name</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">extractor_func</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                    <span class="n">data</span> <span class="o">=</span> <span class="n">extractor_func</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="n">current_extractor_params</span><span class="p">)</span>

                    <span class="c1"># Feature extraction meta information</span>
                    <span class="n">meta</span> <span class="o">=</span> <span class="p">{</span>
                        <span class="s1">&#39;parameters&#39;</span><span class="p">:</span> <span class="n">current_extractor_params</span><span class="p">,</span>
                        <span class="s1">&#39;datetime&#39;</span><span class="p">:</span> <span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2"> %H:%M:%S&quot;</span><span class="p">,</span> <span class="n">gmtime</span><span class="p">()),</span>
                        <span class="s1">&#39;audio_file&#39;</span><span class="p">:</span> <span class="n">audio_file</span><span class="p">,</span>
                        <span class="s1">&#39;extractor_version&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">__version__</span><span class="p">,</span>
                    <span class="p">}</span>

                    <span class="c1"># Create feature container</span>
                    <span class="n">feature_container</span> <span class="o">=</span> <span class="n">FeatureContainer</span><span class="p">(</span><span class="n">features</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">meta</span><span class="o">=</span><span class="n">meta</span><span class="p">)</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">store</span> <span class="ow">and</span> <span class="n">extractor_name</span> <span class="ow">in</span> <span class="n">storage_paths</span><span class="p">:</span>
                        <span class="n">feature_container</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">storage_paths</span><span class="p">[</span><span class="n">extractor_name</span><span class="p">])</span>
                    <span class="n">feature_repository</span><span class="p">[</span><span class="n">extractor_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">feature_container</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: No extraction method for extractor [</span><span class="si">{method}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                        <span class="n">method</span><span class="o">=</span><span class="n">extractor_name</span>
                    <span class="p">)</span>

                    <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">FeatureRepository</span><span class="p">(</span><span class="n">feature_repository</span><span class="p">)</span></div>

<div class="viewcode-block" id="FeatureExtractor.get_default_parameters"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureExtractor.get_default_parameters.html#dcase_framework.features.FeatureExtractor.get_default_parameters">[docs]</a>    <span class="k">def</span> <span class="nf">get_default_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Get default parameters as dict</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        DottedDict</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="n">DottedDict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">default_parameters</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="nf">_mel</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">params</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Mel-band energies</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        data : numpy.ndarray</span>
<span class="sd">            Audio data.</span>
<span class="sd">        params : dict</span>
<span class="sd">            Parameters.</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list of numpy.ndarray</span>
<span class="sd">            List of feature matrices, feature matrix per audio channel.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">window</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_window_function</span><span class="p">(</span>
            <span class="n">N</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;win_length_samples&#39;</span><span class="p">),</span>
            <span class="n">window_type</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;window&#39;</span><span class="p">)</span>
        <span class="p">)</span>

        <span class="n">mel_basis</span> <span class="o">=</span> <span class="n">librosa</span><span class="o">.</span><span class="n">filters</span><span class="o">.</span><span class="n">mel</span><span class="p">(</span>
            <span class="n">sr</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">),</span>
            <span class="n">n_fft</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;n_fft&#39;</span><span class="p">),</span>
            <span class="n">n_mels</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;n_mels&#39;</span><span class="p">),</span>
            <span class="n">fmin</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;fmin&#39;</span><span class="p">),</span>
            <span class="n">fmax</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;fmax&#39;</span><span class="p">),</span>
            <span class="n">htk</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;htk&#39;</span><span class="p">)</span>
        <span class="p">)</span>

        <span class="k">if</span> <span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;normalize_mel_bands&#39;</span><span class="p">):</span>
            <span class="n">mel_basis</span> <span class="o">/=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">mel_basis</span><span class="p">,</span> <span class="n">axis</span><span class="o">=-</span><span class="mi">1</span><span class="p">)[:,</span> <span class="kc">None</span><span class="p">]</span>

        <span class="n">feature_matrix</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">channel</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">data</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
            <span class="n">spectrogram_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_spectrogram</span><span class="p">(</span>
                <span class="n">y</span><span class="o">=</span><span class="n">data</span><span class="p">[</span><span class="n">channel</span><span class="p">,</span> <span class="p">:],</span>
                <span class="n">n_fft</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;n_fft&#39;</span><span class="p">),</span>
                <span class="n">win_length_samples</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;win_length_samples&#39;</span><span class="p">),</span>
                <span class="n">hop_length_samples</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;hop_length_samples&#39;</span><span class="p">),</span>
                <span class="n">spectrogram_type</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;spectrogram_type&#39;</span><span class="p">)</span> <span class="k">if</span> <span class="s1">&#39;spectrogram_type&#39;</span> <span class="ow">in</span> <span class="n">params</span> <span class="k">else</span> <span class="s1">&#39;magnitude&#39;</span><span class="p">,</span>
                <span class="n">center</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                <span class="n">window</span><span class="o">=</span><span class="n">window</span>
            <span class="p">)</span>

            <span class="n">mel_spectrum</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">mel_basis</span><span class="p">,</span> <span class="n">spectrogram_</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;log&#39;</span><span class="p">):</span>
                <span class="n">mel_spectrum</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mel_spectrum</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">eps</span><span class="p">)</span>

            <span class="n">mel_spectrum</span> <span class="o">=</span> <span class="n">mel_spectrum</span><span class="o">.</span><span class="n">T</span>

            <span class="n">feature_matrix</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mel_spectrum</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">feature_matrix</span>

    <span class="k">def</span> <span class="nf">_mfcc</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">params</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Static MFCC</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        data : numpy.ndarray</span>
<span class="sd">            Audio data</span>
<span class="sd">        params : dict</span>
<span class="sd">            Parameters</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list of numpy.ndarray</span>
<span class="sd">            List of feature matrices, feature matrix per audio channel</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">window</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_window_function</span><span class="p">(</span>
            <span class="n">N</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;win_length_samples&#39;</span><span class="p">),</span>
            <span class="n">window_type</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;window&#39;</span><span class="p">)</span>
        <span class="p">)</span>

        <span class="n">mel_basis</span> <span class="o">=</span> <span class="n">librosa</span><span class="o">.</span><span class="n">filters</span><span class="o">.</span><span class="n">mel</span><span class="p">(</span>
            <span class="n">sr</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">),</span>
            <span class="n">n_fft</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;n_fft&#39;</span><span class="p">),</span>
            <span class="n">n_mels</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;n_mels&#39;</span><span class="p">),</span>
            <span class="n">fmin</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;fmin&#39;</span><span class="p">),</span>
            <span class="n">fmax</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;fmax&#39;</span><span class="p">),</span>
            <span class="n">htk</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;htk&#39;</span><span class="p">)</span>
        <span class="p">)</span>

        <span class="k">if</span> <span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;normalize_mel_bands&#39;</span><span class="p">):</span>
            <span class="n">mel_basis</span> <span class="o">/=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">mel_basis</span><span class="p">,</span> <span class="n">axis</span><span class="o">=-</span><span class="mi">1</span><span class="p">)[:,</span> <span class="kc">None</span><span class="p">]</span>

        <span class="n">feature_matrix</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">channel</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">data</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
            <span class="c1"># Calculate Static Coefficients</span>
            <span class="n">spectrogram_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_spectrogram</span><span class="p">(</span>
                <span class="n">y</span><span class="o">=</span><span class="n">data</span><span class="p">[</span><span class="n">channel</span><span class="p">,</span> <span class="p">:],</span>
                <span class="n">n_fft</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;n_fft&#39;</span><span class="p">),</span>
                <span class="n">win_length_samples</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;win_length_samples&#39;</span><span class="p">),</span>
                <span class="n">hop_length_samples</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;hop_length_samples&#39;</span><span class="p">),</span>
                <span class="n">spectrogram_type</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;spectrogram_type&#39;</span><span class="p">)</span> <span class="k">if</span> <span class="s1">&#39;spectrogram_type&#39;</span> <span class="ow">in</span> <span class="n">params</span> <span class="k">else</span> <span class="s1">&#39;magnitude&#39;</span><span class="p">,</span>
                <span class="n">center</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                <span class="n">window</span><span class="o">=</span><span class="n">window</span>
            <span class="p">)</span>

            <span class="n">mel_spectrum</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">mel_basis</span><span class="p">,</span> <span class="n">spectrogram_</span><span class="p">)</span>

            <span class="n">mfcc</span> <span class="o">=</span> <span class="n">librosa</span><span class="o">.</span><span class="n">feature</span><span class="o">.</span><span class="n">mfcc</span><span class="p">(</span><span class="n">S</span><span class="o">=</span><span class="n">librosa</span><span class="o">.</span><span class="n">logamplitude</span><span class="p">(</span><span class="n">mel_spectrum</span><span class="p">),</span>
                                        <span class="n">n_mfcc</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;n_mfcc&#39;</span><span class="p">))</span>

            <span class="n">feature_matrix</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mfcc</span><span class="o">.</span><span class="n">T</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">feature_matrix</span>

    <span class="k">def</span> <span class="nf">_mfcc_delta</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">params</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Delta MFCC</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        data : numpy.ndarray</span>
<span class="sd">            Audio data</span>
<span class="sd">        params : dict</span>
<span class="sd">            Parameters</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list of numpy.ndarray</span>
<span class="sd">            List of feature matrices, feature matrix per audio channel</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">feature_matrix</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">channel</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)):</span>
            <span class="c1"># Delta coefficients</span>
            <span class="n">delta</span> <span class="o">=</span> <span class="n">librosa</span><span class="o">.</span><span class="n">feature</span><span class="o">.</span><span class="n">delta</span><span class="p">(</span>
                <span class="n">data</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span><span class="o">.</span><span class="n">T</span><span class="p">,</span>
                <span class="n">width</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;width&#39;</span><span class="p">)</span>
            <span class="p">)</span>

            <span class="n">feature_matrix</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">delta</span><span class="o">.</span><span class="n">T</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">feature_matrix</span>

    <span class="k">def</span> <span class="nf">_mfcc_acceleration</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">params</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Acceleration MFCC</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        data : numpy.ndarray</span>
<span class="sd">            Audio data</span>
<span class="sd">        params : dict</span>
<span class="sd">            Parameters</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list of numpy.ndarray</span>
<span class="sd">            List of feature matrices, feature matrix per audio channel</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">feature_matrix</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">channel</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)):</span>
            <span class="c1"># Acceleration coefficients (aka delta delta)</span>
            <span class="n">acceleration</span> <span class="o">=</span> <span class="n">librosa</span><span class="o">.</span><span class="n">feature</span><span class="o">.</span><span class="n">delta</span><span class="p">(</span>
                <span class="n">data</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span><span class="o">.</span><span class="n">T</span><span class="p">,</span>
                <span class="n">order</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
                <span class="n">width</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;width&#39;</span><span class="p">)</span>
            <span class="p">)</span>

            <span class="n">feature_matrix</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">acceleration</span><span class="o">.</span><span class="n">T</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">feature_matrix</span>

    <span class="k">def</span> <span class="nf">_load_audio</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">audio_file</span><span class="p">,</span> <span class="n">params</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Load audio using AudioFile class</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        audio_file : str</span>
<span class="sd">        params : dict</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        numpy.ndarray</span>
<span class="sd">            Audio data</span>

<span class="sd">        fs : int</span>
<span class="sd">            Sampling frequency</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># Collect parameters</span>
        <span class="n">mono</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">if</span> <span class="s1">&#39;mono&#39;</span> <span class="ow">in</span> <span class="n">params</span><span class="p">:</span>
            <span class="n">mono</span> <span class="o">=</span> <span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;mono&#39;</span><span class="p">)</span>

        <span class="k">elif</span> <span class="s1">&#39;dependency_parameters&#39;</span> <span class="ow">in</span> <span class="n">params</span> <span class="ow">and</span> <span class="s1">&#39;mono&#39;</span> <span class="ow">in</span> <span class="n">params</span><span class="p">[</span><span class="s1">&#39;dependency_parameters&#39;</span><span class="p">]:</span>
            <span class="n">mono</span> <span class="o">=</span> <span class="n">params</span><span class="p">[</span><span class="s1">&#39;dependency_parameters&#39;</span><span class="p">][</span><span class="s1">&#39;mono&#39;</span><span class="p">]</span>

        <span class="n">fs</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">if</span> <span class="s1">&#39;fs&#39;</span> <span class="ow">in</span> <span class="n">params</span><span class="p">:</span>
            <span class="n">fs</span> <span class="o">=</span> <span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">)</span>

        <span class="k">elif</span> <span class="s1">&#39;dependency_parameters&#39;</span> <span class="ow">in</span> <span class="n">params</span> <span class="ow">and</span> <span class="s1">&#39;fs&#39;</span> <span class="ow">in</span> <span class="n">params</span><span class="p">[</span><span class="s1">&#39;dependency_parameters&#39;</span><span class="p">]:</span>
            <span class="n">fs</span> <span class="o">=</span> <span class="n">params</span><span class="p">[</span><span class="s1">&#39;dependency_parameters&#39;</span><span class="p">][</span><span class="s1">&#39;fs&#39;</span><span class="p">]</span>

        <span class="n">normalize_audio</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">if</span> <span class="s1">&#39;normalize_audio&#39;</span> <span class="ow">in</span> <span class="n">params</span><span class="p">:</span>
            <span class="n">normalize_audio</span> <span class="o">=</span> <span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;normalize_audio&#39;</span><span class="p">)</span>

        <span class="k">elif</span> <span class="s1">&#39;dependency_parameters&#39;</span> <span class="ow">in</span> <span class="n">params</span> <span class="ow">and</span> <span class="s1">&#39;normalize_audio&#39;</span> <span class="ow">in</span> <span class="n">params</span><span class="p">[</span><span class="s1">&#39;dependency_parameters&#39;</span><span class="p">]:</span>
            <span class="n">normalize_audio</span> <span class="o">=</span> <span class="n">params</span><span class="p">[</span><span class="s1">&#39;dependency_parameters&#39;</span><span class="p">][</span><span class="s1">&#39;normalize_audio&#39;</span><span class="p">]</span>

        <span class="c1"># Load audio with correct parameters</span>
        <span class="n">y</span><span class="p">,</span> <span class="n">fs</span> <span class="o">=</span> <span class="n">AudioFile</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">audio_file</span><span class="p">,</span> <span class="n">mono</span><span class="o">=</span><span class="n">mono</span><span class="p">,</span> <span class="n">fs</span><span class="o">=</span><span class="n">fs</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">mono</span><span class="p">:</span>
            <span class="c1"># Make sure mono audio has correct shape</span>
            <span class="n">y</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">])</span>

        <span class="c1"># Normalize audio</span>
        <span class="k">if</span> <span class="n">normalize_audio</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">channel</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">y</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
                <span class="n">y</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_normalize_audio</span><span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="n">channel</span><span class="p">])</span>

        <span class="k">return</span> <span class="n">y</span><span class="p">,</span> <span class="n">fs</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_normalize_audio</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">head_room</span><span class="o">=</span><span class="mf">0.005</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Normalize audio</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        y : numpy.ndarray</span>
<span class="sd">            Audio data</span>
<span class="sd">        head_room : float</span>
<span class="sd">            Head room</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        numpy.ndarray</span>
<span class="sd">            Audio data</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">mean_value</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
        <span class="n">y</span> <span class="o">-=</span> <span class="n">mean_value</span>

        <span class="n">max_value</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="nb">abs</span><span class="p">(</span><span class="n">y</span><span class="p">))</span> <span class="o">+</span> <span class="n">head_room</span>
        <span class="k">return</span> <span class="n">y</span> <span class="o">/</span> <span class="n">max_value</span>

    <span class="k">def</span> <span class="nf">_window_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">N</span><span class="p">,</span> <span class="n">window_type</span><span class="o">=</span><span class="s1">&#39;hamming_asymmetric&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Window function</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        N : int</span>
<span class="sd">            window length</span>

<span class="sd">        window_type : str</span>
<span class="sd">            window type</span>
<span class="sd">            (Default value=&#39;hamming_asymmetric&#39;)</span>
<span class="sd">        Raises</span>
<span class="sd">        ------</span>
<span class="sd">        ValueError:</span>
<span class="sd">            Unknown window type</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">            window function : array</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># Windowing function</span>
        <span class="k">if</span> <span class="n">window_type</span> <span class="o">==</span> <span class="s1">&#39;hamming_asymmetric&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">scipy</span><span class="o">.</span><span class="n">signal</span><span class="o">.</span><span class="n">hamming</span><span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="n">sym</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">window_type</span> <span class="o">==</span> <span class="s1">&#39;hamming_symmetric&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">scipy</span><span class="o">.</span><span class="n">signal</span><span class="o">.</span><span class="n">hamming</span><span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="n">sym</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">window_type</span> <span class="o">==</span> <span class="s1">&#39;hann_asymmetric&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">scipy</span><span class="o">.</span><span class="n">signal</span><span class="o">.</span><span class="n">hann</span><span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="n">sym</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">window_type</span> <span class="o">==</span> <span class="s1">&#39;hann_symmetric&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">scipy</span><span class="o">.</span><span class="n">signal</span><span class="o">.</span><span class="n">hann</span><span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="n">sym</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Unknown window type [</span><span class="si">{window_type}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                <span class="n">window_type</span><span class="o">=</span><span class="n">window_type</span>
            <span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_spectrogram</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span>
                     <span class="n">n_fft</span><span class="o">=</span><span class="mi">1024</span><span class="p">,</span>
                     <span class="n">win_length_samples</span><span class="o">=</span><span class="mf">0.04</span><span class="p">,</span>
                     <span class="n">hop_length_samples</span><span class="o">=</span><span class="mf">0.02</span><span class="p">,</span>
                     <span class="n">window</span><span class="o">=</span><span class="n">scipy</span><span class="o">.</span><span class="n">signal</span><span class="o">.</span><span class="n">hamming</span><span class="p">(</span><span class="mi">1024</span><span class="p">,</span> <span class="n">sym</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span>
                     <span class="n">center</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                     <span class="n">spectrogram_type</span><span class="o">=</span><span class="s1">&#39;magnitude&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Spectrogram</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        y : numpy.ndarray</span>
<span class="sd">            Audio data</span>
<span class="sd">        n_fft : int</span>
<span class="sd">            FFT size</span>
<span class="sd">            Default value &quot;1024&quot;</span>
<span class="sd">        win_length_samples : float</span>
<span class="sd">            Window length in seconds</span>
<span class="sd">            Default value &quot;0.04&quot;</span>
<span class="sd">        hop_length_samples : float</span>
<span class="sd">            Hop length in seconds</span>
<span class="sd">            Default value &quot;0.02&quot;</span>
<span class="sd">        window : array</span>
<span class="sd">            Window function</span>
<span class="sd">            Default value &quot;scipy.signal.hamming(1024, sym=False)&quot;</span>
<span class="sd">        center : bool</span>
<span class="sd">            If true, input signal is padded so to the frame is centered at hop length</span>
<span class="sd">            Default value &quot;True&quot;</span>
<span class="sd">        spectrogram_type : str</span>
<span class="sd">            Type of spectrogram &quot;magnitude&quot; or &quot;power&quot;</span>
<span class="sd">            Default value &quot;magnitude&quot;</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        np.ndarray [shape=(1 + n_fft/2, t), dtype=dtype]</span>
<span class="sd">            STFT matrix</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">spectrogram_type</span> <span class="o">==</span> <span class="s1">&#39;magnitude&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">librosa</span><span class="o">.</span><span class="n">stft</span><span class="p">(</span><span class="n">y</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">eps</span><span class="p">,</span>
                                          <span class="n">n_fft</span><span class="o">=</span><span class="n">n_fft</span><span class="p">,</span>
                                          <span class="n">win_length</span><span class="o">=</span><span class="n">win_length_samples</span><span class="p">,</span>
                                          <span class="n">hop_length</span><span class="o">=</span><span class="n">hop_length_samples</span><span class="p">,</span>
                                          <span class="n">center</span><span class="o">=</span><span class="n">center</span><span class="p">,</span>
                                          <span class="n">window</span><span class="o">=</span><span class="n">window</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">spectrogram_type</span> <span class="o">==</span> <span class="s1">&#39;power&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">librosa</span><span class="o">.</span><span class="n">stft</span><span class="p">(</span><span class="n">y</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">eps</span><span class="p">,</span>
                                          <span class="n">n_fft</span><span class="o">=</span><span class="n">n_fft</span><span class="p">,</span>
                                          <span class="n">win_length</span><span class="o">=</span><span class="n">win_length_samples</span><span class="p">,</span>
                                          <span class="n">hop_length</span><span class="o">=</span><span class="n">hop_length_samples</span><span class="p">,</span>
                                          <span class="n">center</span><span class="o">=</span><span class="n">center</span><span class="p">,</span>
                                          <span class="n">window</span><span class="o">=</span><span class="n">window</span><span class="p">))</span> <span class="o">**</span> <span class="mi">2</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Unknown spectrum type [</span><span class="si">{spectrogram_type}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                <span class="n">spectrogram_type</span><span class="o">=</span><span class="n">spectrogram_type</span>
            <span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_update</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d</span><span class="p">,</span> <span class="n">u</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Recursive dict update</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">iteritems</span><span class="p">(</span><span class="n">u</span><span class="p">):</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">Mapping</span><span class="p">):</span>
                <span class="n">r</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_update</span><span class="p">(</span><span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="p">{}),</span> <span class="n">v</span><span class="p">)</span>
                <span class="n">d</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">r</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">d</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">u</span><span class="p">[</span><span class="n">k</span><span class="p">]</span>
        <span class="k">return</span> <span class="n">d</span></div>


<span class="k">class</span> <span class="nc">FeatureProcessingUnitMixin</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Feature processing chain unit mixin&quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="nf">process</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">feature_data</span><span class="p">):</span>
        <span class="k">pass</span>


<div class="viewcode-block" id="FeatureStacker"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureStacker.html#dcase_framework.features.FeatureStacker">[docs]</a><span class="k">class</span> <span class="nc">FeatureStacker</span><span class="p">(</span><span class="n">FeatureProcessingUnitMixin</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Feature stacker&quot;&quot;&quot;</span>
    <span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;0.0.1&#39;</span>

<div class="viewcode-block" id="FeatureStacker.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureStacker.html#dcase_framework.features.FeatureStacker.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">recipe</span><span class="p">,</span> <span class="n">feature_hop</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Constructor</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        recipe : dict</span>
<span class="sd">            Stacking recipe</span>
<span class="sd">        feature_hop : int, optional</span>
<span class="sd">            Feature hopping</span>
<span class="sd">            Default value 1</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span> <span class="o">=</span> <span class="n">recipe</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">feature_hop</span> <span class="o">=</span> <span class="n">feature_hop</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;logger&#39;</span><span class="p">,</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">))</span></div>

    <span class="k">def</span> <span class="nf">__getstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Return only needed data for pickle&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">{</span>
            <span class="s1">&#39;recipe&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">,</span>
            <span class="s1">&#39;feature_hop&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">feature_hop</span><span class="p">,</span>
        <span class="p">}</span>

    <span class="k">def</span> <span class="nf">__setstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;recipe&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">feature_hop</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;feature_hop&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>

<div class="viewcode-block" id="FeatureStacker.normalizer"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureStacker.normalizer.html#dcase_framework.features.FeatureStacker.normalizer">[docs]</a>    <span class="k">def</span> <span class="nf">normalizer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">normalizer_list</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Stack normalization factors based on stack map</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        normalizer_list : dict</span>
<span class="sd">            List of Normalizer classes</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        dict</span>
<span class="sd">            Stacked normalizer variables in a dict</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># Check that all feature matrices have same amount of frames</span>
        <span class="n">frame_count</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
        <span class="k">for</span> <span class="n">feature</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">:</span>
            <span class="n">method</span> <span class="o">=</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;method&#39;</span><span class="p">]</span>
            <span class="k">if</span> <span class="s1">&#39;vector-index&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">:</span>
                <span class="n">channel</span> <span class="o">=</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;channel&#39;</span><span class="p">]</span>

            <span class="k">else</span><span class="p">:</span>
                <span class="n">channel</span> <span class="o">=</span> <span class="mi">0</span>  <span class="c1"># Default value</span>

            <span class="k">if</span> <span class="n">frame_count</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                <span class="n">frame_count</span> <span class="o">=</span> <span class="n">normalizer_list</span><span class="p">[</span><span class="n">method</span><span class="p">][</span><span class="s1">&#39;N&#39;</span><span class="p">]</span>

            <span class="k">elif</span> <span class="n">frame_count</span> <span class="o">!=</span> <span class="n">normalizer_list</span><span class="p">[</span><span class="n">method</span><span class="p">][</span><span class="s1">&#39;N&#39;</span><span class="p">]:</span>
                <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Normalizers should have seen same number of frames </span><span class="si">{count1}</span><span class="s1"> != </span><span class="si">{count2}</span><span class="s1"> [</span><span class="si">{method}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                    <span class="n">count1</span><span class="o">=</span><span class="n">frame_count</span><span class="p">,</span>
                    <span class="n">count2</span><span class="o">=</span><span class="n">normalizer_list</span><span class="p">[</span><span class="n">method</span><span class="p">][</span><span class="s1">&#39;N&#39;</span><span class="p">],</span>
                    <span class="n">method</span><span class="o">=</span><span class="n">method</span><span class="p">)</span>

                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                <span class="k">raise</span> <span class="ne">AssertionError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

        <span class="n">stacked_mean</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">stacked_std</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="k">for</span> <span class="n">feature</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">:</span>
            <span class="n">method</span> <span class="o">=</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;method&#39;</span><span class="p">]</span>

            <span class="c1"># Default values</span>
            <span class="n">channel</span> <span class="o">=</span> <span class="mi">0</span>
            <span class="k">if</span> <span class="s1">&#39;vector-index&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">:</span>
                <span class="n">channel</span> <span class="o">=</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;channel&#39;</span><span class="p">]</span>

            <span class="k">if</span> <span class="p">(</span><span class="s1">&#39;vector-index&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">feature</span> <span class="ow">or</span>
               <span class="p">(</span><span class="s1">&#39;vector-index&#39;</span> <span class="ow">in</span> <span class="n">feature</span> <span class="ow">and</span> <span class="s1">&#39;full&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">]</span> <span class="ow">and</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;full&#39;</span><span class="p">])):</span>

                <span class="c1"># We have Full matrix</span>
                <span class="n">stacked_mean</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">normalizer_list</span><span class="p">[</span><span class="n">method</span><span class="p">][</span><span class="s1">&#39;mean&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">])</span>
                <span class="n">stacked_std</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">normalizer_list</span><span class="p">[</span><span class="n">method</span><span class="p">][</span><span class="s1">&#39;std&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">])</span>

            <span class="k">elif</span> <span class="p">(</span><span class="s1">&#39;vector-index&#39;</span> <span class="ow">in</span> <span class="n">feature</span> <span class="ow">and</span>
                  <span class="s1">&#39;vector&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">]</span> <span class="ow">and</span>
                  <span class="s1">&#39;selection&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">]</span> <span class="ow">and</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;selection&#39;</span><span class="p">]):</span>

                <span class="c1"># We have selector vector</span>
                <span class="n">stacked_mean</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">normalizer_list</span><span class="p">[</span><span class="n">method</span><span class="p">][</span><span class="s1">&#39;mean&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">][:,</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;vector&#39;</span><span class="p">]])</span>
                <span class="n">stacked_std</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">normalizer_list</span><span class="p">[</span><span class="n">method</span><span class="p">][</span><span class="s1">&#39;std&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">][:,</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;vector&#39;</span><span class="p">]])</span>

            <span class="k">elif</span> <span class="p">(</span><span class="s1">&#39;vector-index&#39;</span> <span class="ow">in</span> <span class="n">feature</span> <span class="ow">and</span>
                  <span class="s1">&#39;start&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">]</span> <span class="ow">and</span>
                  <span class="s1">&#39;end&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">]):</span>

                <span class="c1"># we have start and end index</span>
                <span class="n">stacked_mean</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">normalizer_list</span><span class="p">[</span><span class="n">method</span><span class="p">][</span><span class="s1">&#39;mean&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">][:,</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;start&#39;</span><span class="p">]:</span><span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;end&#39;</span><span class="p">]])</span>
                <span class="n">stacked_std</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">normalizer_list</span><span class="p">[</span><span class="n">method</span><span class="p">][</span><span class="s1">&#39;std&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">][:,</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;start&#39;</span><span class="p">]:</span><span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;end&#39;</span><span class="p">]])</span>

        <span class="n">normalizer</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;mean&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">stacked_mean</span><span class="p">)],</span>
            <span class="s1">&#39;std&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">stacked_std</span><span class="p">)],</span>
            <span class="s1">&#39;N&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">frame_count</span><span class="p">],</span>
        <span class="p">}</span>

        <span class="k">return</span> <span class="n">normalizer</span></div>

<div class="viewcode-block" id="FeatureStacker.feature_vector"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureStacker.feature_vector.html#dcase_framework.features.FeatureStacker.feature_vector">[docs]</a>    <span class="k">def</span> <span class="nf">feature_vector</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">feature_repository</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Feature vector creation</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        feature_repository : FeatureRepository, dict</span>
<span class="sd">            Feature repository with needed features</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        FeatureContainer</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># Check that all feature matrices have same amount of frames</span>
        <span class="n">frame_count</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
        <span class="k">for</span> <span class="n">feature</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">:</span>
            <span class="n">method</span> <span class="o">=</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;method&#39;</span><span class="p">]</span>
            <span class="n">channel</span> <span class="o">=</span> <span class="mi">0</span>  <span class="c1"># Default value</span>
            <span class="k">if</span> <span class="s1">&#39;vector-index&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">:</span>
                <span class="n">channel</span> <span class="o">=</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;channel&#39;</span><span class="p">]</span>

            <span class="k">if</span> <span class="n">frame_count</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                <span class="n">frame_count</span> <span class="o">=</span> <span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

            <span class="k">elif</span> <span class="n">frame_count</span> <span class="o">!=</span> <span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
                <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Feature matrices should have same number of frames </span><span class="si">{count1}</span><span class="s1"> != </span><span class="si">{count2}</span><span class="s1"> [</span><span class="si">{method}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                    <span class="n">count1</span><span class="o">=</span><span class="n">frame_count</span><span class="p">,</span>
                    <span class="n">count2</span><span class="o">=</span><span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                    <span class="n">method</span><span class="o">=</span><span class="n">method</span>
                <span class="p">)</span>

                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                <span class="k">raise</span> <span class="ne">AssertionError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

        <span class="c1"># Stack features</span>
        <span class="n">feature_matrix</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">feature</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">:</span>
            <span class="n">method</span> <span class="o">=</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;method&#39;</span><span class="p">]</span>

            <span class="c1"># Default values</span>
            <span class="n">channel</span> <span class="o">=</span> <span class="mi">0</span>
            <span class="k">if</span> <span class="s1">&#39;vector-index&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">:</span>
                <span class="n">channel</span> <span class="o">=</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;channel&#39;</span><span class="p">]</span>

            <span class="k">if</span> <span class="p">(</span><span class="s1">&#39;vector-index&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">feature</span> <span class="ow">or</span>
               <span class="p">(</span><span class="s1">&#39;vector-index&#39;</span> <span class="ow">in</span> <span class="n">feature</span> <span class="ow">and</span> <span class="s1">&#39;full&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">]</span> <span class="ow">and</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;full&#39;</span><span class="p">])):</span>

                <span class="c1"># We have Full matrix</span>
                <span class="n">feature_matrix</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">][::</span><span class="bp">self</span><span class="o">.</span><span class="n">feature_hop</span><span class="p">,</span> <span class="p">:])</span>

            <span class="k">elif</span> <span class="p">(</span><span class="s1">&#39;vector-index&#39;</span> <span class="ow">in</span> <span class="n">feature</span> <span class="ow">and</span>
                  <span class="s1">&#39;vector&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">]</span> <span class="ow">and</span>
                  <span class="s1">&#39;selection&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">]</span> <span class="ow">and</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;selection&#39;</span><span class="p">]):</span>

                <span class="n">index</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;vector&#39;</span><span class="p">])</span>
                <span class="c1"># We have selector vector</span>
                <span class="n">feature_matrix</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">][::</span><span class="bp">self</span><span class="o">.</span><span class="n">feature_hop</span><span class="p">,</span> <span class="n">index</span><span class="p">])</span>

            <span class="k">elif</span> <span class="p">(</span><span class="s1">&#39;vector-index&#39;</span> <span class="ow">in</span> <span class="n">feature</span> <span class="ow">and</span>
                  <span class="s1">&#39;start&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">]</span> <span class="ow">and</span>
                  <span class="s1">&#39;end&#39;</span> <span class="ow">in</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">]):</span>

                <span class="c1"># we have start and end index</span>
                <span class="n">feature_matrix</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">][::</span><span class="bp">self</span><span class="o">.</span><span class="n">feature_hop</span><span class="p">,</span> <span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;start&#39;</span><span class="p">]:</span><span class="n">feature</span><span class="p">[</span><span class="s1">&#39;vector-index&#39;</span><span class="p">][</span><span class="s1">&#39;end&#39;</span><span class="p">]])</span>

        <span class="n">meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;parameters&#39;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s1">&#39;fs&#39;</span><span class="p">:</span> <span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s1">&#39;parameters&#39;</span><span class="p">][</span><span class="s1">&#39;fs&#39;</span><span class="p">],</span>
                <span class="s1">&#39;win_length_seconds&#39;</span><span class="p">:</span> <span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s1">&#39;parameters&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;win_length_seconds&#39;</span><span class="p">),</span>
                <span class="s1">&#39;win_length_samples&#39;</span><span class="p">:</span> <span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s1">&#39;parameters&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;win_length_samples&#39;</span><span class="p">),</span>
                <span class="s1">&#39;hop_length_seconds&#39;</span><span class="p">:</span> <span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s1">&#39;parameters&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;hop_length_seconds&#39;</span><span class="p">),</span>
                <span class="s1">&#39;hop_length_samples&#39;</span><span class="p">:</span> <span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s1">&#39;parameters&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;hop_length_samples&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="s1">&#39;datetime&#39;</span><span class="p">:</span> <span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2"> %H:%M:%S&quot;</span><span class="p">,</span> <span class="n">gmtime</span><span class="p">()),</span>
            <span class="s1">&#39;audio_file&#39;</span><span class="p">:</span> <span class="n">feature_repository</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s1">&#39;audio_file&#39;</span><span class="p">],</span>
            <span class="s1">&#39;extractor_version&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="k">return</span> <span class="n">FeatureContainer</span><span class="p">(</span><span class="n">features</span><span class="o">=</span><span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">feature_matrix</span><span class="p">)],</span> <span class="n">meta</span><span class="o">=</span><span class="n">meta</span><span class="p">)</span></div>

<div class="viewcode-block" id="FeatureStacker.process"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureStacker.process.html#dcase_framework.features.FeatureStacker.process">[docs]</a>    <span class="k">def</span> <span class="nf">process</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">feature_data</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Feature vector creation</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        feature_data : FeatureRepository</span>
<span class="sd">            Feature repository with needed features</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        FeatureContainer</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">feature_vector</span><span class="p">(</span><span class="n">feature_repository</span><span class="o">=</span><span class="n">feature_data</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="FeatureNormalizer"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureNormalizer.html#dcase_framework.features.FeatureNormalizer">[docs]</a><span class="k">class</span> <span class="nc">FeatureNormalizer</span><span class="p">(</span><span class="n">DataFile</span><span class="p">,</span> <span class="n">ContainerMixin</span><span class="p">,</span> <span class="n">FeatureProcessingUnitMixin</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Feature normalizer</span>

<span class="sd">    Accumulates feature statistics</span>

<span class="sd">    Examples</span>
<span class="sd">    --------</span>

<span class="sd">    &gt;&gt;&gt; normalizer = FeatureNormalizer()</span>
<span class="sd">    &gt;&gt;&gt; for feature_matrix in training_items:</span>
<span class="sd">    &gt;&gt;&gt;     normalizer.accumulate(feature_matrix)</span>
<span class="sd">    &gt;&gt;&gt;</span>
<span class="sd">    &gt;&gt;&gt; normalizer.finalize()</span>

<span class="sd">    &gt;&gt;&gt; for feature_matrix in test_items:</span>
<span class="sd">    &gt;&gt;&gt;     feature_matrix_normalized = normalizer.normalizer(feature_matrix)</span>
<span class="sd">    &gt;&gt;&gt;     # used the features</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;0.0.1&#39;</span>

<div class="viewcode-block" id="FeatureNormalizer.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureNormalizer.html#dcase_framework.features.FeatureNormalizer.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stat</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">feature_matrix</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;__init__ method.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        stat : dict or None</span>
<span class="sd">            Pre-calculated statistics in dict to initialize internal state</span>

<span class="sd">        feature_matrix : numpy.ndarray [shape=(frames, number of feature values)] or None</span>
<span class="sd">            Feature matrix to be used in the initialization</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">stat</span><span class="p">:</span>
            <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span>
                    <span class="s1">&#39;N&#39;</span><span class="p">:</span> <span class="p">[],</span>
                    <span class="s1">&#39;S1&#39;</span><span class="p">:</span> <span class="p">[],</span>
                    <span class="s1">&#39;S2&#39;</span><span class="p">:</span> <span class="p">[],</span>
                    <span class="s1">&#39;mean&#39;</span><span class="p">:</span> <span class="p">[],</span>
                    <span class="s1">&#39;std&#39;</span><span class="p">:</span> <span class="p">[],</span>
                <span class="p">}</span>
            <span class="n">defaults</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">stat</span><span class="p">)</span>
            <span class="nb">super</span><span class="p">(</span><span class="n">DataFile</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">defaults</span><span class="p">)</span>

        <span class="k">elif</span> <span class="n">feature_matrix</span> <span class="ow">and</span> <span class="n">stat</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="nb">super</span><span class="p">(</span><span class="n">DataFile</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
                <span class="p">{</span>
                    <span class="s1">&#39;N&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">feature_matrix</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]],</span>
                    <span class="s1">&#39;S1&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">feature_matrix</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)],</span>
                    <span class="s1">&#39;S2&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">feature_matrix</span> <span class="o">**</span> <span class="mi">2</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)],</span>
                    <span class="s1">&#39;mean&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">feature_matrix</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)],</span>
                    <span class="s1">&#39;std&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">std</span><span class="p">(</span><span class="n">feature_matrix</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)],</span>
                <span class="p">}</span>
            <span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">finalize</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">super</span><span class="p">(</span><span class="n">DataFile</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
                <span class="p">{</span>
                    <span class="s1">&#39;N&#39;</span><span class="p">:</span> <span class="p">[],</span>
                    <span class="s1">&#39;S1&#39;</span><span class="p">:</span> <span class="p">[],</span>
                    <span class="s1">&#39;S2&#39;</span><span class="p">:</span> <span class="p">[],</span>
                    <span class="s1">&#39;mean&#39;</span><span class="p">:</span> <span class="p">[],</span>
                    <span class="s1">&#39;std&#39;</span><span class="p">:</span> <span class="p">[],</span>
                <span class="p">}</span>
            <span class="p">)</span></div>

    <span class="k">def</span> <span class="nf">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span>

    <span class="k">def</span> <span class="nf">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">type</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">traceback</span><span class="p">):</span>
        <span class="c1"># Finalize accumulated calculation</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">finalize</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">__getstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="c1"># Return only needed data for pickle</span>
        <span class="k">return</span> <span class="p">{</span>
            <span class="s1">&#39;N&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">],</span>
            <span class="s1">&#39;S1&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S1&#39;</span><span class="p">],</span>
            <span class="s1">&#39;S2&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S2&#39;</span><span class="p">],</span>
            <span class="s1">&#39;mean&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">],</span>
            <span class="s1">&#39;std&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">],</span>
        <span class="p">}</span>

    <span class="k">def</span> <span class="nf">__setstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">N</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">S1</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;S1&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">S2</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;S2&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mean</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">std</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">]</span>

<div class="viewcode-block" id="FeatureNormalizer.accumulate"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureNormalizer.accumulate.html#dcase_framework.features.FeatureNormalizer.accumulate">[docs]</a>    <span class="k">def</span> <span class="nf">accumulate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">feature_container</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Accumulate statistics</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        feature_container : FeatureContainer</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">stat</span> <span class="o">=</span> <span class="n">feature_container</span><span class="o">.</span><span class="n">stat</span>
        <span class="k">for</span> <span class="n">channel</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">stat</span><span class="p">)):</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">])</span> <span class="o">&lt;=</span> <span class="n">channel</span><span class="p">:</span>
                <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">channel</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>

            <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">+=</span> <span class="n">stat</span><span class="p">[</span><span class="n">channel</span><span class="p">][</span><span class="s1">&#39;N&#39;</span><span class="p">]</span>

            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">])</span> <span class="o">&lt;=</span> <span class="n">channel</span><span class="p">:</span>
                <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">channel</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
            <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">+=</span> <span class="n">stat</span><span class="p">[</span><span class="n">channel</span><span class="p">][</span><span class="s1">&#39;mean&#39;</span><span class="p">]</span>

            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S1&#39;</span><span class="p">])</span> <span class="o">&lt;=</span> <span class="n">channel</span><span class="p">:</span>
                <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S1&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">channel</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
            <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S1&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">+=</span> <span class="n">stat</span><span class="p">[</span><span class="n">channel</span><span class="p">][</span><span class="s1">&#39;S1&#39;</span><span class="p">]</span>

            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S2&#39;</span><span class="p">])</span> <span class="o">&lt;=</span> <span class="n">channel</span><span class="p">:</span>
                <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S2&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">channel</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
            <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S2&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">+=</span> <span class="n">stat</span><span class="p">[</span><span class="n">channel</span><span class="p">][</span><span class="s1">&#39;S2&#39;</span><span class="p">]</span>
        <span class="k">return</span> <span class="bp">self</span></div>

<div class="viewcode-block" id="FeatureNormalizer.finalize"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureNormalizer.finalize.html#dcase_framework.features.FeatureNormalizer.finalize">[docs]</a>    <span class="k">def</span> <span class="nf">finalize</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Finalize statistics calculation</span>

<span class="sd">        Accumulated values are used to get mean and std for the seen feature data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        None</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">for</span> <span class="n">channel</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">])):</span>
            <span class="c1"># Finalize statistics</span>
            <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S1&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">/</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span>

            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">])</span> <span class="o">&lt;=</span> <span class="n">channel</span><span class="p">:</span>
                <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">channel</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
            <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">sqrt</span><span class="p">((</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S2&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">-</span> <span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S1&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;S1&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]))</span> <span class="o">/</span> <span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)))</span>

            <span class="c1"># In case we have very brain-death material we get std = Nan =&gt; 0.0</span>
            <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">nan_to_num</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">])</span>

            <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">])</span>
            <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="bp">self</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">])</span>
        <span class="k">return</span> <span class="bp">self</span></div>

<div class="viewcode-block" id="FeatureNormalizer.normalize"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureNormalizer.normalize.html#dcase_framework.features.FeatureNormalizer.normalize">[docs]</a>    <span class="k">def</span> <span class="nf">normalize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">feature_container</span><span class="p">,</span> <span class="n">channel</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Normalize feature matrix with internal statistics of the class</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        feature_container : numpy.ndarray [shape=(frames, number of feature values)]</span>
<span class="sd">            Feature matrix to be normalized</span>
<span class="sd">        channel : int</span>
<span class="sd">            Feature channel</span>
<span class="sd">            Default value &quot;0&quot;</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        feature_matrix : numpy.ndarray [shape=(frames, number of feature values)]</span>
<span class="sd">            Normalized feature matrix</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">feature_container</span><span class="p">,</span> <span class="n">FeatureContainer</span><span class="p">):</span>
            <span class="n">feature_container</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">feature_container</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span> <span class="o">-</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">])</span> <span class="o">/</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span>
            <span class="k">return</span> <span class="n">feature_container</span>

        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">feature_container</span><span class="p">,</span> <span class="n">numpy</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span>
            <span class="k">return</span> <span class="p">(</span><span class="n">feature_container</span> <span class="o">-</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">])</span> <span class="o">/</span> <span class="bp">self</span><span class="p">[</span><span class="s1">&#39;std&#39;</span><span class="p">][</span><span class="n">channel</span><span class="p">]</span></div>

<div class="viewcode-block" id="FeatureNormalizer.process"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureNormalizer.process.html#dcase_framework.features.FeatureNormalizer.process">[docs]</a>    <span class="k">def</span> <span class="nf">process</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">feature_data</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Normalize feature matrix with internal statistics of the class</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        feature_data : FeatureContainer or numpy.ndarray [shape=(frames, number of feature values)]</span>
<span class="sd">            Feature matrix to be normalized</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        feature_matrix : numpy.ndarray [shape=(frames, number of feature values)]</span>
<span class="sd">            Normalized feature matrix</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span><span class="p">(</span><span class="n">feature_container</span><span class="o">=</span><span class="n">feature_data</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="FeatureAggregator"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureAggregator.html#dcase_framework.features.FeatureAggregator">[docs]</a><span class="k">class</span> <span class="nc">FeatureAggregator</span><span class="p">(</span><span class="n">FeatureProcessingUnitMixin</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Feature aggregator&quot;&quot;&quot;</span>
    <span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;0.0.1&#39;</span>

    <span class="n">valid_method</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;mean&#39;</span><span class="p">,</span> <span class="s1">&#39;std&#39;</span><span class="p">,</span> <span class="s1">&#39;cov&#39;</span><span class="p">,</span> <span class="s1">&#39;kurtosis&#39;</span><span class="p">,</span> <span class="s1">&#39;skew&#39;</span><span class="p">,</span> <span class="s1">&#39;flatten&#39;</span><span class="p">]</span>

<div class="viewcode-block" id="FeatureAggregator.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureAggregator.html#dcase_framework.features.FeatureAggregator.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Constructor</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        recipe : list of dict or list of str</span>
<span class="sd">            Aggregation recipe, supported methods [mean, std, cov, kurtosis, skew, flatten].</span>
<span class="sd">        win_length_frames : int</span>
<span class="sd">            Window length in feature frames</span>
<span class="sd">        hop_length_frames : int</span>
<span class="sd">            Hop length in feature frames</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;recipe&#39;</span><span class="p">),</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span> <span class="o">=</span> <span class="p">[</span><span class="n">d</span><span class="p">[</span><span class="s1">&#39;method&#39;</span><span class="p">]</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;recipe&#39;</span><span class="p">)]</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;recipe&#39;</span><span class="p">),</span> <span class="nb">list</span><span class="p">):</span>
            <span class="n">recipe</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;recipe&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">recipe</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">dict</span><span class="p">):</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span> <span class="o">=</span> <span class="p">[</span><span class="n">d</span><span class="p">[</span><span class="s1">&#39;method&#39;</span><span class="p">]</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;recipe&#39;</span><span class="p">)]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span> <span class="o">=</span> <span class="n">recipe</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">win_length_frames</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;win_length_frames&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">hop_length_frames</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;hop_length_frames&#39;</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="nf">__getstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="c1"># Return only needed data for pickle</span>
        <span class="k">return</span> <span class="p">{</span>
            <span class="s1">&#39;recipe&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">,</span>
            <span class="s1">&#39;win_length_frames&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">win_length_frames</span><span class="p">,</span>
            <span class="s1">&#39;hop_length_frames&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">hop_length_frames</span><span class="p">,</span>
        <span class="p">}</span>

    <span class="k">def</span> <span class="nf">__setstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;recipe&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">win_length_frames</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;win_length_frames&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">hop_length_frames</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;hop_length_frames&#39;</span><span class="p">]</span>

<div class="viewcode-block" id="FeatureAggregator.process"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureAggregator.process.html#dcase_framework.features.FeatureAggregator.process">[docs]</a>    <span class="k">def</span> <span class="nf">process</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">feature_data</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Process features</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        feature_data : FeatureContainer</span>
<span class="sd">            Features to be aggregated</span>
<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        FeatureContainer</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># Not the most efficient way as numpy stride_tricks would produce</span>
        <span class="c1"># faster code, however, opted for cleaner presentation this time.</span>
        <span class="n">feature_data_per_channel</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">channel</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">feature_data</span><span class="o">.</span><span class="n">channels</span><span class="p">):</span>
            <span class="n">aggregated_features</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">frame</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">feature_data</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">hop_length_frames</span><span class="p">):</span>
                <span class="c1"># Get start and end of the window, keep frame at the middle (approximately)</span>
                <span class="n">start_frame</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">frame</span> <span class="o">-</span> <span class="n">numpy</span><span class="o">.</span><span class="n">floor</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">win_length_frames</span><span class="o">/</span><span class="mf">2.0</span><span class="p">))</span>
                <span class="n">end_frame</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">frame</span> <span class="o">+</span> <span class="n">numpy</span><span class="o">.</span><span class="n">ceil</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">win_length_frames</span> <span class="o">/</span> <span class="mf">2.0</span><span class="p">))</span>

                <span class="n">frame_id</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="n">start_frame</span><span class="p">,</span> <span class="n">end_frame</span><span class="p">))</span>
                <span class="c1"># If start of feature matrix, pad with first frame</span>
                <span class="n">frame_id</span><span class="p">[</span><span class="n">frame_id</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>

                <span class="c1"># If end of the feature matrix, pad with last frame</span>
                <span class="n">frame_id</span><span class="p">[</span><span class="n">frame_id</span> <span class="o">&gt;</span> <span class="n">feature_data</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">feature_data</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span>

                <span class="n">current_frame</span> <span class="o">=</span> <span class="n">feature_data</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">][</span><span class="n">frame_id</span><span class="p">,</span> <span class="p">:]</span>
                <span class="n">aggregated_frame</span> <span class="o">=</span> <span class="p">[]</span>

                <span class="k">if</span> <span class="s1">&#39;mean&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">:</span>
                    <span class="n">aggregated_frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">current_frame</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">))</span>

                <span class="k">if</span> <span class="s1">&#39;std&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">:</span>
                    <span class="n">aggregated_frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">current_frame</span><span class="o">.</span><span class="n">std</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">))</span>

                <span class="k">if</span> <span class="s1">&#39;cov&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">:</span>
                    <span class="n">aggregated_frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">cov</span><span class="p">(</span><span class="n">current_frame</span><span class="p">)</span><span class="o">.</span><span class="n">flatten</span><span class="p">())</span>

                <span class="k">if</span> <span class="s1">&#39;kurtosis&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">:</span>
                    <span class="n">aggregated_frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">scipy</span><span class="o">.</span><span class="n">stats</span><span class="o">.</span><span class="n">kurtosis</span><span class="p">(</span><span class="n">current_frame</span><span class="p">))</span>

                <span class="k">if</span> <span class="s1">&#39;skew&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">:</span>
                    <span class="n">aggregated_frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">scipy</span><span class="o">.</span><span class="n">stats</span><span class="o">.</span><span class="n">skew</span><span class="p">(</span><span class="n">current_frame</span><span class="p">))</span>

                <span class="k">if</span> <span class="s1">&#39;flatten&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">:</span>
                    <span class="n">aggregated_frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">current_frame</span><span class="o">.</span><span class="n">flatten</span><span class="p">())</span>

                <span class="k">if</span> <span class="n">aggregated_frame</span><span class="p">:</span>
                    <span class="n">aggregated_features</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">concatenate</span><span class="p">(</span><span class="n">aggregated_frame</span><span class="p">))</span>

            <span class="n">feature_data_per_channel</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">vstack</span><span class="p">(</span><span class="n">aggregated_features</span><span class="p">))</span>

        <span class="n">meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;parameters&#39;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s1">&#39;recipe&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">recipe</span><span class="p">,</span>
                <span class="s1">&#39;win_length_frames&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">win_length_frames</span><span class="p">,</span>
                <span class="s1">&#39;hop_length_frames&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">hop_length_frames</span><span class="p">,</span>
            <span class="p">},</span>
            <span class="s1">&#39;datetime&#39;</span><span class="p">:</span> <span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2"> %H:%M:%S&quot;</span><span class="p">,</span> <span class="n">gmtime</span><span class="p">()),</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="s1">&#39;audio_file&#39;</span> <span class="ow">in</span> <span class="n">feature_data</span><span class="o">.</span><span class="n">meta</span><span class="p">:</span>
            <span class="n">meta</span><span class="p">[</span><span class="s1">&#39;audio_file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">feature_data</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s1">&#39;audio_file&#39;</span><span class="p">]</span>

        <span class="k">return</span> <span class="n">FeatureContainer</span><span class="p">(</span><span class="n">features</span><span class="o">=</span><span class="n">feature_data_per_channel</span><span class="p">,</span> <span class="n">meta</span><span class="o">=</span><span class="n">meta</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="FeatureMasker"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureMasker.html#dcase_framework.features.FeatureMasker">[docs]</a><span class="k">class</span> <span class="nc">FeatureMasker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Feature masker&quot;&quot;&quot;</span>
    <span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;0.0.1&#39;</span>

<div class="viewcode-block" id="FeatureMasker.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureMasker.html#dcase_framework.features.FeatureMasker.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Constructor</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        hop_length_seconds : float</span>
<span class="sd">            Hop length in seconds</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">hop_length_seconds</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;hop_length_seconds&#39;</span><span class="p">)</span>

        <span class="c1"># Initialize mask events</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mask_events</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span></div>

    <span class="k">def</span> <span class="nf">__getstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="c1"># Return only needed data for pickle</span>
        <span class="k">return</span> <span class="p">{</span>
            <span class="s1">&#39;hop_length_seconds&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">hop_length_seconds</span><span class="p">,</span>
        <span class="p">}</span>

    <span class="k">def</span> <span class="nf">__setstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">hop_length_seconds</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s1">&#39;hop_length_seconds&#39;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mask_events</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">set_mask</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mask_events</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Set masking events</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        mask_events : list of MetaItems or MetaDataContainer</span>
<span class="sd">            Event list used for masking</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">mask_events</span> <span class="o">=</span> <span class="n">mask_events</span>
        <span class="k">return</span> <span class="bp">self</span>

    <span class="k">def</span> <span class="nf">masking</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">feature_data</span><span class="p">,</span> <span class="n">mask_event</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Masking feature repository with given events</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        feature_data : FeatureRepository</span>
<span class="sd">        mask_events : list of MetaItems or MetaDataContainer</span>
<span class="sd">            Event list used for masking</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        FeatureRepository</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">for</span> <span class="n">method</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">feature_data</span><span class="o">.</span><span class="n">keys</span><span class="p">()):</span>
            <span class="n">removal_mask</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="n">feature_data</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">bool</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">mask_event</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask_events</span><span class="p">:</span>
                <span class="n">onset_frame</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">floor</span><span class="p">(</span><span class="n">mask_event</span><span class="o">.</span><span class="n">event_onset</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">hop_length_seconds</span><span class="p">))</span>
                <span class="n">offset_frame</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">ceil</span><span class="p">(</span><span class="n">mask_event</span><span class="o">.</span><span class="n">event_offset</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">hop_length_seconds</span><span class="p">))</span>
                <span class="k">if</span> <span class="n">offset_frame</span> <span class="o">&gt;</span> <span class="n">feature_data</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
                    <span class="n">offset_frame</span> <span class="o">=</span> <span class="n">feature_data</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                <span class="n">removal_mask</span><span class="p">[</span><span class="n">onset_frame</span><span class="p">:</span><span class="n">offset_frame</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span>

            <span class="k">for</span> <span class="n">channel</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">feature_data</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">channels</span><span class="p">):</span>
                <span class="n">feature_data</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">]</span> <span class="o">=</span> <span class="n">feature_data</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="o">.</span><span class="n">feat</span><span class="p">[</span><span class="n">channel</span><span class="p">][</span><span class="n">removal_mask</span><span class="p">,</span> <span class="p">:]</span>

        <span class="k">return</span> <span class="n">feature_data</span>

<div class="viewcode-block" id="FeatureMasker.process"><a class="viewcode-back" href="../../generated/dcase_framework.features.FeatureMasker.process.html#dcase_framework.features.FeatureMasker.process">[docs]</a>    <span class="k">def</span> <span class="nf">process</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">feature_data</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Process feature repository</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        feature_data : FeatureRepository</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        FeatureRepository</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask_events</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">masking</span><span class="p">(</span><span class="n">feature_data</span><span class="o">=</span><span class="n">feature_data</span><span class="p">,</span> <span class="n">mask_event</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">mask_events</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">feature_data</span></div></div>

</pre></div>

           </div>
           <div class="articleComments">
            
           </div>
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017, Toni Heittola et al..

    </p>
  </div> 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../../',
            VERSION:'1.0',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </script>
      <script type="text/javascript" src="../../_static/jquery.js"></script>
      <script type="text/javascript" src="../../_static/underscore.js"></script>
      <script type="text/javascript" src="../../_static/doctools.js"></script>

  

  
  
    <script type="text/javascript" src="../../_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>